Download the PHP package philiprehberger/php-pipeline without Composer
On this page you can find all versions of the php package philiprehberger/php-pipeline. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download philiprehberger/php-pipeline
More information about philiprehberger/php-pipeline
Files in philiprehberger/php-pipeline
Package php-pipeline
Short Description Composable pipeline pattern for processing data through ordered stages
License MIT
Homepage https://github.com/philiprehberger/php-pipeline
Informations about the package php-pipeline
PHP Pipeline
Composable pipeline pattern for processing data through ordered stages.
Requirements
- PHP 8.2+
Installation
Usage
Basic Pipeline
Class-Based Stages
Implement the Stage contract for reusable, testable stages:
Conditional Stages
Pipeline Context
Share state between stages using PipelineContext:
Tap
Add side-effect stages that observe the payload without modifying it:
Validation Checkpoints
Insert validation steps between stages to abort the pipeline on invalid data:
If the checkpoint returns false or throws, a CheckpointFailedException is thrown.
Stage Profiling
Profile stage execution time and memory usage:
Pipeline Templates
Register reusable pipeline configurations:
Typed Exception Handling
Catch specific exception types and recover gracefully:
Error Handling
API
| Method | Description |
|---|---|
Pipeline::send(mixed $passable) |
Create a new pipeline with the given data |
Pipeline::register(string $name, callable $builder) |
Register a reusable pipeline template |
Pipeline::fromTemplate(string $name) |
Create a pipeline from a registered template |
Pipeline::hasTemplate(string $name) |
Check if a template is registered |
->through(array $stages) |
Set the array of stages |
->pipe(string\|callable $stage) |
Append a single stage |
->when(bool $condition, string\|callable $stage) |
Add stage if condition is true |
->unless(bool $condition, string\|callable $stage) |
Add stage if condition is false |
->withContext(PipelineContext $context) |
Attach shared context passed to stages |
->tap(callable $fn) |
Add a side-effect stage that does not modify the payload |
->checkpoint(callable $validator) |
Insert a validation checkpoint between stages |
->profile() |
Enable profiling mode |
->catchException(string $class, callable $handler) |
Register a handler for a specific exception type |
->onFailure(callable $handler) |
Register a failure handler |
->process() |
Execute the pipeline and return the result |
->processWithProfile() |
Execute and return a ProfiledResult with timing data |
->thenReturn() |
Alias for process() |
Development
Support
If you find this project useful:
License
MIT