componenta/pipeline
Composer 安装命令:
composer require componenta/pipeline
包简介
PSR-15 middleware pipeline for Componenta
README 文档
README
PSR-15 middleware pipeline for the Componenta framework.
Installation
composer require componenta/pipeline
The package declares Componenta\Http\Middleware\PipelineConfigProvider in extra.componenta.config-providers.
When componenta/composer-plugin is installed, the provider is added to the generated provider list automatically.
Related Packages
| Package | Why it matters here |
|---|---|
psr/http-server-middleware |
Defines MiddlewareInterface and RequestHandlerInterface. |
componenta/app-http |
Runs HTTP applications on top of the pipeline; concrete middleware and response emission live in separate HTTP packages. |
componenta/router |
Usually sits near the end of the HTTP pipeline. |
componenta/middleware-factory |
Creates middleware from strings, classes, groups, and callables. |
Usage
As a top-level handler
use Componenta\Http\Middleware\Pipeline; $pipeline = new Pipeline( [$errorMiddleware, $authMiddleware, $routerMiddleware], fallbackHandler: $notFoundHandler, ); $response = $pipeline->handle($request);
If no fallbackHandler is supplied, EmptyPipelineHandler is installed and throws RuntimeException on invocation — this surfaces misconfiguration of an empty pipeline.
Nested pipelines
A pipeline is itself a middleware, so pipelines compose:
$api = new Pipeline([$apiAuth, $apiRouter]); $web = new Pipeline([$sessionMiddleware, $webRouter]); $app = new Pipeline([$errorMiddleware], $notFoundHandler) ->pipe($api) ->pipe($web);
Via the factory
$pipeline = $factory->createMiddlewarePipeline( [$auth, $router], $notFoundHandler, );
Behavior
- Middleware execute in registration order (FIFO).
pipe()returns a new pipeline; the original is not modified.- Returning a response from a middleware without calling the next handler halts the chain.
- Exceptions from middleware and terminal handlers propagate unchanged.
Errors
| Condition | Exception |
|---|---|
Non-middleware element in constructor / pipe() |
InvalidArgumentException |
Pipeline appended to itself via pipe() |
RuntimeException |
Pipeline passed as its own handler to process() |
RuntimeException |
| Empty pipeline invoked without a custom fallback | RuntimeException |
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-14