Simple PSR-15 Middleware Handler
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.