PHPackages                             chefhasteeth/pipeline - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. chefhasteeth/pipeline

ActiveLibrary

chefhasteeth/pipeline
=====================

v1.0.5(1y ago)18049.5k↑38.3%61MITPHPPHP ^8.1.0

Since Jun 6Pushed 1y ago2 watchersCompare

[ Source](https://github.com/chefhasteeth/pipeline)[ Packagist](https://packagist.org/packages/chefhasteeth/pipeline)[ RSS](/packages/chefhasteeth-pipeline/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (7)Used By (1)

Pipelines, Supercharged!
========================

[](#pipelines-supercharged)

[![Example code showcasing the Pipeline package using the with transaction method and the pipable trait](https://raw.githubusercontent.com/chefhasteeth/pipeline/master/example.png)](https://raw.githubusercontent.com/chefhasteeth/pipeline/master/example.png)

Installation
------------

[](#installation)

Install via composer:

```
composer require chefhasteeth/pipeline
```

What are pipelines used for?
----------------------------

[](#what-are-pipelines-used-for)

A Pipeline allows you to pass data through a series of *pipes* to perform a sequence of operations with the data. Each pipe is a callable piece of code: An invokable class, a closure, etc. Since each pipe operates on the data in isolation (the pipes don't know or care about each other), then that means you can easily compose complex workflows out of reusable actions that are also very easy to test—because they aren't interdependent.

What makes it supercharged?
---------------------------

[](#what-makes-it-supercharged)

If Laravel is the **batteries included** PHP Framework, then this package can be considered the batteries included version of the `Illuminate\Pipeline\Pipeline` class. It remains (mostly) compatible with Laravel's pipeline, but there are a few differences and added features.

For example, do you see that `withTransaction()` method above? That will tell the Pipeline that we want to run this within a database transaction, which will automatically commit or roll back at the end, depending on whether the pipeline succeeded or failed. It also comes with a trait that gives you a `pipeThrough()` method to automatically send the object it's implemented on through a pipeline.

What are the differences?
-------------------------

[](#what-are-the-differences)

In Laravel's `Pipeline` class, *pipes* are essentially callables that receive two arguments: The `$passable`, which is the data passed to the pipe, and a `$next` callback that calls the next pipe.

For the purposes of this package, I wanted my pipes to be used easily from anywhere, not just in the pipeline. (For example, this could take the form of a `GenerateThumbnail` action that appears as part of a pipeline, but also might appear in a cron job.) In other words, I don't want to have to pass an empty closure to the class or function to satisfy that `$next` argument.

That's the biggest difference between this package and Laravel's `Pipeline`: The output of the current pipe is the input of the next pipe.

Sending pipes down the pipeline
-------------------------------

[](#sending-pipes-down-the-pipeline)

When configuring the pipeline, you can send an array of class strings, invokable objects, closures, objects with a `handle()` method, or any other type that passes `is_callable()`.

```
use Chefhasteeth\Pipeline\Pipeline;

class RegisterController
{
    public function store(StoreRegistrationRequest $request)
    {
        return Pipeline::make()
            ->send($request->all())
            ->through([
                RegisterUser::class,
                AddMemberToTeam::class,
                SendWelcomeEmail::class,
            ])
            ->then(fn ($data) => UserResource::make($data));
    }
}
```

Another approach you can take is to implement this as a trait on a data object. (You could even implement it on your `FormRequest` object if you really wanted.)

```
use Chefhasteeth\Pipeline\Pipable;

class UserDataObject
{
    use Pipable;

    public string $name;
    public string $email;
    public string $password;
    // ...
}

class RegisterController
{
    public function store(StoreRegistrationRequest $request)
    {
        return UserDataObject::fromRequest($request)
            ->pipeThrough([
                RegisterUser::class,
                AddMemberToTeam::class,
                SendWelcomeEmail::class,
            ])
            ->then(fn ($data) => UserResource::make($data));
    }
}
```

To maintain compatibility with Laravel's `Pipeline` class, the `through()` method can accept either a single array of callables or multiple parameters, where each parameter is one of the callable types listed previously. However, the `pipeThrough()` trait method only accepts an array, since it also has a second optional parameter.

Using database transactions
---------------------------

[](#using-database-transactions)

When you want to use database transactions in your pipeline, the method will be different depending on if you're using the trait or the `Pipeline` class.

Using the `Pipeline` class:

```
Pipeline::make()->withTransaction()
```

The `withTransaction()` method will tell the pipeline to use transactions. When you call the `then()` or `thenReturn()` methods, a database transaction will begin before executing the pipes. If an exception is encountered during the pipeline, the transaction will be rolled back so no data is committed to the database. Assuming the pipeline completed successfully, the transaction is committed.

When using the trait, you can pass a second parameter to the `pipeThrough()` method:

```
$object->pipeThrough($pipes, withTransaction: true);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance44

Moderate activity, may be stable

Popularity46

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~199 days

Recently: every ~249 days

Total

6

Last Release

444d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e486216dd69ea74174f1f1cacb6ad467d54e89e0ae0eb4f6a932f9512c9c122?d=identicon)[chefhasteeth](/maintainers/chefhasteeth)

---

Top Contributors

[![chefhasteeth](https://avatars.githubusercontent.com/u/20307133?v=4)](https://github.com/chefhasteeth "chefhasteeth (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")

---

Tags

laravelpipepipeline

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/chefhasteeth-pipeline/health.svg)

```
[![Health](https://phpackages.com/badges/chefhasteeth-pipeline/health.svg)](https://phpackages.com/packages/chefhasteeth-pipeline)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
