Laravel Pipeline with DB transaction support, events and additional methods

Overview

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


#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 you can make 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 use the pipeline helper:

pipeline($data, [
    // pipes
])->thenReturn();

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

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.

Comments
  • Add `run` helper

    Add `run` helper

    About

    This is the convenient way to run a single action that is pipeline-compatible.

    Instead of:

    pipeline($data, MyAction::class)
      ->thenReturn();
    

    You would use:

    run(MyAction::class, $data);
    

    By default, it uses handle method in your action classes, but you can customize it by adding code to your ServiceProvider:

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

    With this configuration, the pipeline in run helper will use the execute underlying method.


    enhancement 
    opened by michael-rubel 0
  • Make parameters optional in `pipeline` helper

    Make parameters optional in `pipeline` helper

    About

    Since v2.1.0 it was required to pass a passable and pipes parameters to the pipeline helper. They're now optional.

    pipeline()
      ->send($data)
      ->through(Pipe::class)
      ->thenReturn();
    
    enhancement 
    opened by michael-rubel 0
  • Events

    Events

    About

    This PR adds a possibility to enable firing events throughout the pipeline.

    To use this feature, you need to invoke withEvents method on the pipeline chain.

    app(Pipeline::class)
      ->withEvents()
      ->send('data')
      ->through(Pipe::class)
      ->thenReturn();
    

    Currently, two events are available:

    • PipeStarted - fired before execution of current pipe;
    • PipePassed - fired after execution of current pipe.
    enhancement 
    opened by michael-rubel 0
  • Add `pipeline` helper

    Add `pipeline` helper

    About

    Adds a pipeline helper following community request in https://github.com/laravel/framework/discussions/43429

    Any suggestions to improve an actual implementation are appreciated. 🙂

    enhancement 
    opened by michael-rubel 0
  • Use `Laravel Pint` instead of `PHP_CodeSniffer`

    Use `Laravel Pint` instead of `PHP_CodeSniffer`

    Logo Laravel Pint

    Introduction

    Laravel Pint is an opinionated PHP code style fixer for minimalists. Pint is built on top of PHP-CS-Fixer and makes it simple to ensure that your code style stays clean and consistent.

    enhancement 
    opened by michael-rubel 0
Releases(3.2.1)
  • 3.2.1(Dec 10, 2022)

    What's Changed

    • Drop Laravel 8 and support PHP 8.2 🐘 by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/10

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/3.2.0...3.2.1

    Source code(tar.gz)
    Source code(zip)
  • 3.2.0(Oct 31, 2022)

    What's Changed

    • Add run helper by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/9

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/3.1.0...3.2.0

    Source code(tar.gz)
    Source code(zip)
  • 3.1.0(Aug 11, 2022)

    What's Changed

    • Make parameters optional in pipeline helper by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/7

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/3.0.0...3.1.0

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Aug 10, 2022)

    What's Changed

    • Events by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/5

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/2.1.0...3.0.0

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Aug 10, 2022)

    What's Changed

    • Add pipeline helper by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/3

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/2.0.0...2.1.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Aug 1, 2022)

    What's Changed

    • Use Laravel Pint instead of PHP_CodeSniffer by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/1
    • Fix transaction rollback when onFailure is used by @michael-rubel in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/2

    New Contributors

    • @michael-rubel made their first contribution in https://github.com/michael-rubel/laravel-enhanced-pipeline/pull/1

    Full Changelog: https://github.com/michael-rubel/laravel-enhanced-pipeline/compare/1.1.0...2.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Michael Rubél
Laravel Certified Developer
Michael Rubél
Collection pipeline library for PHP

Knapsack Collection pipeline library for PHP Knapsack is a collection library for PHP >= 5.6 that implements most of the sequence operations proposed

Dušan Kasan 540 Dec 17, 2022
Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP

About Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP. How to use Windowy comes with 3 registered inventories us

DayKoala ʕ•ᴥ•ʔ 19 Aug 12, 2022
Paddle.com API integration for Laravel with support for webhooks/events

Laravel Paddle This package provides an integration with Paddle.com for Laravel. Read the blogpost about the introduction of the package! Features Sup

Protone Media 179 Dec 16, 2022
Paddle.com API integration for Laravel with support for webhooks/events

Laravel Paddle This package provides an integration with Paddle.com for Laravel. Read the blogpost about the introduction of the package! Features Sup

Protone Media 180 Jan 1, 2023
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.

IP is an immutable value object for (both version 4 and 6) IP addresses. Several helper methods are provided for ranges, broadcast and network address

Darsyn 224 Dec 28, 2022
A redacted PHP port of Underscore.js with additional functions and goodies – Available for Composer and Laravel

Underscore.php The PHP manipulation toolbelt First off : Underscore.php is not a PHP port of Underscore.js (well ok I mean it was at first). It's does

Emma Fabre 1.1k Dec 11, 2022
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Icinga 25 Sep 18, 2022
OctoberCMS BlogHub Plugin - Extends RainLab's Blog extension with custom meta details, additional archives and more.

BlogHub extends the RainLab.Blog OctoberCMS plugin with many necessary and helpful features such as Moderatable Comments, Promotable Tags, Custom Meta Fields, additional Archives, basic Statistics, Views counter and more.

rat.md 5 Dec 15, 2022
This script allows to bypass Oracle Cloud Infrastructure 'Out of host capacity' error immediately when additional OCI capacity will appear in your Home Region / Availability domain.

Resolving Oracle Cloud "Out of Capacity" issue and getting free VPS with 4 ARM cores / 24GB of memory Very neat and useful configuration was recently

Alexander Hitrov 323 Jan 6, 2023
Auto-expiring tags with additional payload data on any eloquent model.

Laravel TempTag Auto-expiring tags with additional payload data on any eloquent model. Installation first you need to install and configure mongodb in

masoud nazarpoor 2 Sep 18, 2021
Magento 2 module for displaying additional information in configuration

AvS_ScopeHint for Magento 2 Displays a hint when a configuration value is overwritten on a lower scope (website or store view). Facts version: 1.0.0-b

Andreas von Studnitz 131 Dec 14, 2022
It's a CodeIgniter Library for Captcha Generation. With additional Flexibility .

Original Source : Pavel Tzonkov <[email protected]> Source Link : http://gscripts.net/free-php-scripts/Anti_Spam_Scripts/Image_Validator/d

Chris # 4 Sep 2, 2022
A bundle to handle encoding and decoding of parameters using OpenSSL and Doctrine lifecycle events.

SpecShaper Encrypt Bundle A bundle to handle encoding and decoding of parameters using OpenSSL and Doctrine lifecycle events. Features include: Master

Mark Ogilvie 48 Nov 4, 2022
An un-offical API wrapper for logsnag.com to get notifications and track your project events

An un-offical API wrapper for logsnag.com to get notifications and track your project events

David Oti 3 Oct 15, 2022
Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countable features.

Laravel Plans Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countabl

ángel 2 Oct 2, 2022
A Pocketmine-MP plugin to add King Of The Hill events to your server.

KOTH KOTH is an event popular on HCF and Faction servers. This plugin lets you add this minigame to you server. Support For questions, please join the

ItsMax123 9 Sep 17, 2022
Generates a static website of metal music events in Leipzig

About EN: This projects generates a static website of metal music events in Leipzig (Ger). DE: Dieses Projekt erstellt einen Webkalender zu diversen M

null 3 Dec 15, 2022
OwnagePE Staff Events Core

An events plugin created for discord.gg/ownage enabling staff members to host small scale events within the respective server.

null 2 Aug 9, 2022
A XOOPS module for handling events, including online registrations.

wgEvents A XOOPS module for handling events, including online registrations. Support If you like the wgEvents module and thanks to the long process fo

XOOPS 2.5.x Modules 6 Dec 15, 2022