minormous/dispatch
Composer 安装命令:
composer require minormous/dispatch
包简介
An HTTP Interop compatible middleware dispatcher
README 文档
README
An HTTP Interop compatible middleware dispatcher in Minormous. Attempts to be PSR-1, PSR-2, PSR-4, PSR-7, and PSR-15 compliant.
Heavily influenced by the design of Tari by ircmaxwell.
For more information, see the documentation.
Install
composer require minormous/dispatch
Usage
The MiddlewareCollection is a container for middleware that acts as the entry point.
It takes two arguments:
- An array of
$middlewarewhich must be instances of server middleware. - A callable
$defaultthat acts as the terminator for the collection and returns an empty response.
Once the collection is prepared it can dispatched with a server request and will return the response for output.
Example
use Minormous\Dispatch\MiddlewareCollection; // Any implementation of PSR-15 MiddlewareInterface $middleware = [ new FooMiddleware(), // ... ]; // Default handler for end of collection $default = function (ServerRequestInterface $request) { // Any implementation of PSR-7 ResponseInterface return new Response(); }; $collection = new MiddlewareCollection($middleware); // Any implementation of PSR-7 ServerRequestInterface $request = ServerRequest::fromGlobals(); $response = $collection->dispatch($request, $default);
Nested Collections
The MiddlewareCollection also implements the MiddlewareInterface to allow
collections to be nested:
use Minormous\Dispatch\MiddlewareCollection; // Any implementation of PSR-15 MiddlewareInterface $middleware = [ new FooMiddleware(), // A nested collection new MiddlewareCollection(...), // More middleware new BarMiddleware(), // ... ]; $collection = new MiddlewareCollection($middleware); // HTTP factories can also be used $default = [$responseFactory, 'createResponse']; $request = $serverRequestFactory->createRequest($_SERVER); $response = $collection->dispatch($request, $default);
minormous/dispatch 适用场景与选型建议
minormous/dispatch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 minormous/dispatch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 minormous/dispatch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-13