16
JunLaravel Enhanced Pipeline is a package that offers Laravel pipelines with DB transaction support and handy additional methods.
You can install this package using composer:
composer require michael-rubel/laravel-enhanced-pipeline
Import modified pipeline to your class:
use MichaelRubel\EnhancedPipeline\Pipeline;
Then you can make the pipeline:
Pipeline::make()
->withTransaction()
->send($data)
->through([
// your pipes
])
->onFailure(function ($data, $exception, $pipe) {
// do something when exception caught
return $data;
})->then(function ($data) {
// do something when all pipes completed their work
return $data;
});
You can as well instantiate the pipeline using IoC or manually:
app(Pipeline::class)
...
(new Pipeline(app()))
...
(new Pipeline)
->setContainer(app())
...
If you want to override the original Pipeline resolved through IoC Container, you can add binding in the ServiceProvider register
method:
$this->app->singleton(\Illuminate\Pipeline\Pipeline::class, \MichaelRubel\EnhancedPipeline\Pipeline::class);
For more details, you can visit its documentation and source code on Github.
Published at : 16-06-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project