承接 phpnomad/fastroute-rest-integration 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpnomad/fastroute-rest-integration

最新稳定版本:1.0.7

Composer 安装命令:

composer require phpnomad/fastroute-rest-integration

包简介

description

README 文档

README

Latest Version Total Downloads PHP Version License

Integrates nikic/fast-route with phpnomad/rest as a runtime REST router. This is the standard non-WordPress RestStrategy for PHPNomad applications. It hosts controllers defined against phpnomad/rest inside a FastRoute dispatcher, binds PHP-superglobal-backed Request and Response implementations for phpnomad/http, and dispatches routes in response to a RequestInitiated event.

Installation

The Composer package name is phpnomad/fastroute-rest-integration, even though the repository is named fastroute-integration.

composer require phpnomad/fastroute-rest-integration

What This Provides

  • RestStrategy implementing PHPNomad\Rest\Interfaces\RestStrategy, backed by nikic/fast-route. It registers controllers as FastRoute handlers, runs any middleware declared on the controller, and runs interceptors after the response is built.
  • Request and Response classes that implement the phpnomad/http interfaces. Request reads from $_SERVER, $_REQUEST, and php://input. Response is an in-memory status, headers, and body holder with JSON and error helpers.
  • RestInitializer, a loader initializer that registers the bindings above and attaches a DispatchRequest listener to the RequestInitiated event.

Requirements

Usage

Add RestInitializer to the initializer list you pass to the Bootstrapper. Once load() runs, your controllers are routed through FastRoute and dispatched when a RequestInitiated event fires.

<?php

use PHPNomad\Core\Bootstrap\CoreInitializer;
use PHPNomad\Di\Container\Container;
use PHPNomad\FastRoute\Component\RestInitializer;
use PHPNomad\Loader\Bootstrapper;

$container = new Container();

(new Bootstrapper(
    $container,
    new CoreInitializer(),
    new RestInitializer(),
    new MyAppInitializer()
))->load();

MyAppInitializer is where you register your own controllers via HasControllers. See the bootstrapping guide at phpnomad.com for the full picture.

Documentation

Full PHPNomad documentation lives at phpnomad.com, including the phpnomad/rest reference and the bootstrapping guide. Upstream router documentation lives at nikic/fast-route.

License

MIT. See LICENSE.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-18