hulotte/middleware-dispatcher

PSR-15 中间件分发器

1.0.0 2020-12-24 17:06 UTC

This package is auto-updated.

Last update: 2024-09-25 01:35:37 UTC


README

描述

Hulotte 中间件分发器是一个允许您通过队列系统管理中间件启动的包。此包遵循 PSR15 标准。

安装

安装 Hulotte 中间件分发器最简单的方式是使用 Composer,使用以下命令:

$ composer require hulotte/middleware-dispatcher

如何使用 Hulotte 中间件分发器?

首先,使用中间件数组实例化 MiddlewareDispatcher 类。

$dispatcher = new \Hulotte\Middlewares\MiddlewareDispatcher([
    new Middleware1(), 
    new Middleware2(),
]);

数组中中间件的顺序很重要:它代表中间件将播放的顺序。

现在您可以调用 handle 方法。请求必须实现 ServerRequestInterface(PSR7 标准)。

$dispatcher->handle($request);