chubbyphp / chubbyphp-framework-router-fastroute
Fastroute router implementation for chubbyphp-framework.
Installs: 21 469
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/chubbyphp/chubbyphp-framework-router-fastroute
Requires
- php: ^8.3
- chubbyphp/chubbyphp-framework: ^5.2
- chubbyphp/chubbyphp-http-exception: ^1.2
- nikic/fast-route: ^1.3|2.0.0-beta1|^2.0
- psr/http-message: ^1.1|^2.0
Requires (Dev)
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-mock: ^2.0.1
- guzzlehttp/psr7: ^2.8
- http-interop/http-factory-guzzle: ^1.2
- infection/infection: ^0.31.9
- laminas/laminas-diactoros: ^3.8
- nyholm/psr7: ^1.8.2
- php-coveralls/php-coveralls: ^2.9
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.32
- phpunit/phpunit: ^12.4.5
- slim/psr7: ^1.8
- sunrise/http-message: ^3.7
README
Description
Fastroute Router implementation for chubbyphp-framework.
Requirements
- php: ^8.3
- chubbyphp/chubbyphp-framework: ^5.2
- chubbyphp/chubbyphp-http-exception: ^1.2
- nikic/fast-route: ^1.3|2.0.0-beta1|^2.0
- psr/http-message: ^1.1|^2.0
Installation
Through Composer as chubbyphp/chubbyphp-framework-router-fastroute.
composer require chubbyphp/chubbyphp-framework-router-fastroute "^2.3"
Usage
<?php declare(strict_types=1); namespace App; use Chubbyphp\Framework\Application; use Chubbyphp\Framework\Middleware\ExceptionMiddleware; use Chubbyphp\Framework\Middleware\RouteMatcherMiddleware; use Chubbyphp\Framework\RequestHandler\CallbackRequestHandler; use Chubbyphp\Framework\Router\FastRoute\RouteMatcher; use Chubbyphp\Framework\Router\Route; use Chubbyphp\Framework\Router\RoutesByName; use Psr\Http\Message\ServerRequestInterface; use Slim\Psr7\Factory\ResponseFactory; use Slim\Psr7\Factory\ServerRequestFactory; require __DIR__.'/vendor/autoload.php'; $responseFactory = new ResponseFactory(); $app = new Application([ new ExceptionMiddleware($responseFactory, true), new RouteMatcherMiddleware(new RouteMatcher(new RoutesByName([ Route::get('/hello/{name:[a-z]+}', 'hello', new CallbackRequestHandler( static function (ServerRequestInterface $request) use ($responseFactory) { $response = $responseFactory->createResponse(); $response->getBody()->write(sprintf('Hello, %s', $request->getAttribute('name'))); return $response; } )) ]))), ]); $app->emit($app->handle((new ServerRequestFactory())->createFromGlobals()));
Copyright
2025 Dominik Zogg