jpirnat / middleware
PSR-15 middleware dispatcher using PSR-11 to retrieve middlewares
Installs: 2 223
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- psr/container: ^1.0 || ^2.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
README
This is a basic PSR-15 middleware dispatcher using PSR-11 ContainerInterface to retrieve middlewares.
Usage
$app = function (ServerRequestInterface $request) : ResponseInterface { // This closure will be executed at the center of the middleware stack. // Use it to wrap your application, or to return a default response. } $dispatcher = new Dispatcher($container, $app); $dispatcher->addMiddlewares([ ExampleMiddleware::class, // identifiers for $container // ... ]); $response = $dispatcher->handle($request);