PSR-15 middleware pipeline for the Componenta framework.
composer require componenta/pipelineThe 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.
| 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. |
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.
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);$pipeline = $factory->createMiddlewarePipeline(
[$auth, $router],
$notFoundHandler,
);- 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.
| 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 |