mpociot/pipeline
Lightweight PHP pipeline implementation (based on illuminate/pipeline) without requiring the Illuminate container. Send an object through an array of middleware/handlers and finish with a callback—useful for middleware-style request/command processing.
mpociot/pipeline package excels in implementing linear, synchronous workflows (e.g., request processing, data transformation, or business logic chains) with a Laravel-inspired API. It aligns well with architectures requiring modular, composable execution flows where each step can inspect, modify, or halt the pipeline (e.g., auth → validation → logging).mpociot/pipeline) is minimal (~1MB).illuminate/pipeline will face zero learning curve. Example:
// Laravel-style pipeline (identical syntax)
$response = (new Pipeline)
->send($request)
->through([$middleware1, $middleware2])
->then(fn($data) => $data);
Middleware::fromPsr15($psrMiddleware)) for interoperability.handle($data, Closure $next) signature.array_reduce), making it suitable for high-throughput systems.league/pipeline (active maintenance).react/promise) for parallel pipelines.Pipeline::send()->catch()).league/pipeline.php-pipeline (PSR-15 compliant).spatie/async-pipeline or react/promise.validate → transform → export).spatie/async-pipeline).league/pipeline or php-pipeline for active maintenance.if/else chains, nested callbacks) for pipeline candidates.league/pipeline: Active maintenance, async support.php-pipeline: PSR-15 compliant, modern PHP.// Before (spaghetti)
$data = $validator->validate($request);
$data = $enricher->addMetadata($data);
// After (pipeline)
(new Pipeline)
->send($request)
->through([$validator, $enricher])
->then(fn($data) => $data);
composer.json:
"mpociot/pipeline": "1.0.0"
ARCHITECTURE_DECISIONS.md.array() syntax changes).composer platform checks:
"config": {
"platform-check": true,
"platform": {
"php": "8.1"
}
}
handle($data, Closure $next).Middleware::fromPsr15()).MiddlewareDispatcher with Pipeline.HttpKernel replacement).league/pipeline.array() changes).league/pipeline if maintenance becomes untenable.->then(...)->catch(function (\Exception $e, $data) {
log::error("Pipeline failed at data: " . json_encode($data), ['exception' => $e]);
});
handle() method contracts.dd() or var_dump() for pipeline inspection.How can I help you explore Laravel packages today?