phpnomad/fastroute-rest-integration
最新稳定版本:1.0.7
Composer 安装命令:
composer require phpnomad/fastroute-rest-integration
包简介
description
README 文档
README
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
RestStrategyimplementingPHPNomad\Rest\Interfaces\RestStrategy, backed bynikic/fast-route. It registers controllers as FastRoute handlers, runs any middleware declared on the controller, and runs interceptors after the response is built.RequestandResponseclasses that implement thephpnomad/httpinterfaces.Requestreads from$_SERVER,$_REQUEST, andphp://input.Responseis an in-memory status, headers, and body holder with JSON and error helpers.RestInitializer, a loader initializer that registers the bindings above and attaches aDispatchRequestlistener to theRequestInitiatedevent.
Requirements
phpnomad/rest, the abstraction this integration implementsphpnomad/loader, to run the initializernikic/fast-route, pulled in automatically by Composer
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
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-18