jpirnat/middleware

此软件包的最新版本(4.0.1)没有提供许可信息。

使用 PSR-11 检索中间件的 PSR-15 中间件调度器

4.0.1 2023-04-17 16:55 UTC

This package is auto-updated.

Last update: 2024-09-17 20:05:37 UTC


README

这是一个基本的 PSR-15 中间件调度器,使用 PSR-11 ContainerInterface 检索中间件。

使用方法

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