Download the PHP package teewurst/pipeline without Composer
On this page you can find all versions of the php package teewurst/pipeline. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pipeline
Simple Recursive Pipeline with few dependencies
With this lib, we are able to separate long executions into multiple tasks. A pipeline enables you to better fulfill single responsibility requirements. This results in better maintainability and testability.
How to
- The Pipeline passes the Payload and its self into the task.
public function __invoke(PayloadInterface $payload, PipelineInterface $pipeline): PayloadInterface;
- The first task calls the next task, calls the next task, calls the next task ...
$payloadAfterAllSteps = $pipeline->handle($payload);
- Like in PSR-7 (the request object) you are now able to handle all information by adding and getting information from a payload object
Step-by-Step
- Create Task(s)
- Initialize Pipeline
- Fill Payload
- Execute Pipe
- Evaluate Pipe
Use Pipeline Service
You are able to simple create your pipelines from your DI (PSR-11 Container Service Manager required). It just takes two lines of code (+Config)
The PipelineService
class allows you to pass tasks as service hashes.
``
With teewurst/Pipeline you are able to create quite complex tasks in no time:
### Best Practices
- Use `RecursivePipeline` to create "Sub Pipelines" => Dynamic Tasks
- Because of the Structure every task has a "before handle next step" and "after handle next step"
- Interrupt pipeline by throwing an exception or return $payload without handling the next step
### Examples
##### Initialize Pipeline manually
Of course it would be better to use DI instead of `new` all the time
##### Simple Task which does something
Use the pipeline object to pass configuration and handle data between tasks
##### Exception Handling Task
Handle (maybe only certain) exceptions within the pipe
##### Error Bag
Process multiple errors with error bags