pawel-jakowczyk / routing
RoutingMiddleware which implements the Psr MiddlewareInterface
1.0.0
2021-05-19 18:01 UTC
Requires
- psr/http-server-middleware: ^1.0
- symfony/psr-http-message-bridge: ^2.1
- symfony/routing: ^5.2
Requires (Dev)
- laminas/laminas-diactoros: ^2.5
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-04-20 03:02:00 UTC
README
This repository holds the RoutingMiddleware which implements the Psr\Http\Server\MiddlewareInterface. It can be instantiated by create method which requires symfony RouteCollection, or it can be instantiated by constructor which requires the RequestMatcherInterface object.
Instalation
composer require pawel-jakowczyk/routing
Usage
use Laminas\Diactoros\ServerRequest; use PJ\Routing\RoutingMiddleware; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Server\RequestHandlerInterface; use Symfony\Component\Routing\RouteCollection; $middleware = RoutingMiddleware::create(new RouteCollection()); $middleware->process( new ServerRequest(), new class() implements RequestHandlerInterface { public function handle(ServerRequestInterface $request): ResponseInterface { return new Response(); } } );