moirei / pipeline
Simple Laravel pipeline library.
Requires
- php: ^8.0
- illuminate/contracts: ^7|^8|^9
- illuminate/support: ^7|^8|^9
- laravel/helpers: ^1.5
Requires (Dev)
- illuminate/contracts: ^7|^8|^9
- laravel/pint: ^1.2
- orchestra/testbench: ^7.5
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- phpunit/phpunit: ^9.5
- spatie/invade: ^1.1
- thled/pest-plugin-shorthands: ^1.1
This package is auto-updated.
Last update: 2025-02-23 10:08:50 UTC
README
Amongst several pipeline packages, including Laravel's very own package, you might want a solution with a bit more regor for complex operations.
This package is intended for data processing and should not be a replacement for actions nor jobs. The concept of a pipeline here is a structured collection of micro tasks that happen in succession in order to yield a single output from a single input.
Documentation
All documentation is available at the documentation site.
Features
- Utility operators
- Pipeline context
- Use closures, handler classes or context methods
Example
If you're used to RxJs, you might have an appreciation for the below example. There's technically no limit to what can be done with pipelines.
$value = Pipeline::with(0)->pipe([ Pipeline::switch([ fn ($v) => $v + 1, fn ($v) => $v + 2, fn ($v) => $v + 3, ]), Pipeline::map( fn ($v) => $v * 2, ), Pipeline::tap(function (array $value) { // do whatever }), ]); // returns [2, 4, 6]
See rationale for a more exciting example.
Installation
composer require moirei/pipeline
Tests
composer test