phpnomad / fastroute-rest-integration
description
Package info
github.com/phpnomad/fastroute-integration
pkg:composer/phpnomad/fastroute-rest-integration
Requires
- nikic/fast-route: ^1.3
- phpnomad/auth: ^1.0
- phpnomad/event: ^1.0
- phpnomad/http: ^1.1
- phpnomad/loader: ^1.0 || ^2.0
- phpnomad/rest: ^2.0
This package is auto-updated.
Last update: 2026-04-10 02:12:21 UTC
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.