New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

michael-rubel/laravel-enhanced-pipeline

Laravel Pipeline with DB transaction support, events and additional methods.
23,901 55
Install
composer require michael-rubel/laravel-enhanced-pipeline
Latest Version:5.0.0
PHP:^8.1
Laravel:10 · 11 · 12
Older releases:9
License:MIT
Last Updated:Jun 23, 2025
Links: GitHub  ·  Packagist
Maintainer: michael-rubel

Enhanced Pipeline in Laravel

Laravel Enhanced Pipeline

Latest Version on Packagist Total Downloads Code Quality Code Coverage GitHub Tests Action Status PHPStan

Laravel Pipeline with DB transaction support, events and additional methods.

The package requires PHP 8.1 or higher and Laravel 10 or higher.


#StandWithUkraine

SWUbanner

Installation

Install the package using composer:

composer require michael-rubel/laravel-enhanced-pipeline

Usage

Import modified pipeline to your class:

use MichaelRubel\EnhancedPipeline\Pipeline;

Then use the pipeline:

Pipeline::make()
    ->withEvents()
    ->withTransaction()
    ->send($data)
    ->through([
        // your pipes
    ])
    ->onFailure(function ($data, $exception) {
        // 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 the service container or manually:

app(Pipeline::class)
    ...

(new Pipeline(app()))
    ...

(new Pipeline)
    ->setContainer(app())
    ...

You can use the run method to execute a single pipe:

$pipeline = Pipeline::make();

$pipeline->run(Pipe::class, $data);

By default, run uses the handle method in your class as an entry point, but if you use a different method name in your pipelines, you can fix that by adding code to your ServiceProvider:

$this->app->resolving(Pipeline::class, function ($pipeline) {
    return $pipeline->via('execute');
});

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);

Transaction

Usage of withTransaction method will enable a manual DB transaction throughout the pipeline execution.

Events

Usage of withEvents method will enable Laravel Events throughout the pipeline execution.

Available events

Testing

composer test

Credits

  • chefhasteeth for base implementation of DB transaction in Pipeline.
  • rezaamini-ir for inspiration to create a pipeline with onFailure method. See #PR

License

The MIT License (MIT). Please see License File for more information.

Related Packages

michael-rubel/laravel-couponables

This package provides polymorphic coupon functionality for your Laravel applicat...

111,914 195
michael-rubel/laravel-formatters

This package is a collection of classes you can use to standardize data formats...

96,071 94
michael-rubel/laravel-value-objects

It is an example template for Laravel packages. Fill or change it the way you li...

38,494 205
michael-rubel/laravel-enhanced-container

This package provides DX tweaks for Service Container in Laravel.

116,264 88
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701

Version History

Version Released PHP Laravel License
5.0.0 ^8.1 ^10.0|^11.0|^12.0 MIT
4.0.1 ^8.1 ^10.0|^11.0 MIT
4.0.0 ^8.1 ^10.0|^11.0 MIT
3.2.3 ^8.0 ^9.0|^10.0 MIT
3.2.2 ^8.0 ^9.0|^10.0 MIT