Simple PSR-15 Middleware Handler
- php: >=7.3
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- doctrine/coding-standard: ^5.0
- nyholm/psr7: ^1.1
- phpstan/phpstan: ^0.11.2
- phpstan/phpstan-phpunit: ^0.11.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2023-05-25 05:26:55 UTC
Simple queue based PSR-15 Middleware Handler.
composer require idiosyncratic/http-middlewarehandler
Composing an instance requires:
- A fallback request handler implementing
- One or more middlewares implementing
use Idiosyncratic\Http\Middleware\MiddlewareRequestHandler; $handler = new MiddlewareRequestHandler( new PsrRequestHandler(), new PsrMiddlewareOne(), new PsrMiddlewareTwo(), new PsrMiddlewareThree(), ); $response = $handler->handle($psrServerRequest);
While most PHP applications are designed so that script lifetime is for a single request,
MiddlewareRequestHandler is designed to be usable in long lived scripts, such as an application built with a ReactPHP or a similar library. Therefore, it is expected that middlewares and the services that they use are stateless as a single instance may service multiple requests.