jpirnat/middleware

There is no license information available for the latest version (4.0.1) of this package.

PSR-15 middleware dispatcher using PSR-11 to retrieve middlewares

4.0.1 2023-04-17 16:55 UTC

This package is auto-updated.

Last update: 2024-04-17 19:18:18 UTC


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);