PHPackages                             sassnowski/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. sassnowski/pipeline

ActiveLibrary

sassnowski/pipeline
===================

A simple pipeline implementation for PHP.

0.1.1(9y ago)5342MITPHPPHP &gt;=5.5

Since May 3Pushed 9y agoCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

PHP Pipeline
============

[](#php-pipeline)

[![Build Status](https://camo.githubusercontent.com/f61d8b6753b731e2c9eba4d6fe1ce74d83aeea6b91a0dc7c19c8691308c427d8/68747470733a2f2f7472617669732d63692e6f72672f6b736173736e6f77736b692f706970656c696e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ksassnowski/pipeline)[![Code Climate](https://camo.githubusercontent.com/93247ed6b0d587d7c36f8aebb3a515708ac77d745fd08e61b94a85a49f6850b1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b736173736e6f77736b692f706970656c696e652f6261646765732f6770612e737667)](https://codeclimate.com/github/ksassnowski/pipeline)[![Test Coverage](https://camo.githubusercontent.com/10b6dcda789978b543b209b841c1a37e7c4ceec65eb812728b8ff9571f066bd1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b736173736e6f77736b692f706970656c696e652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/ksassnowski/pipeline/coverage)[![SensioLabsInsight](https://camo.githubusercontent.com/a37920e5b29d52ce2abd09eb157a897ea881e75dd15520404c4aaa4ac7f08c10/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38616537366163322d366266372d343732332d623262632d3461643631653065383338312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/8ae76ac2-6bf7-4723-b2bc-4ad61e0e8381)

A simple Pipeline implementation for PHP.

Summary
-------

[](#summary)

This package enables you to send a value through a sequence of steps. Each step operates on the return value of the previous step. Without a pipeline you would end up with deeply nested function calls like this.

```
fn5(fn4(fn3(fn2(fn1($initialValue)))));
```

Using a pipeline you can transform the above example to this:

```
Pipeline::pipe($initialValue)
    ->through($fn1)
    ->through($fn2)
    ->through($fn3)
    ->through($fn4)
    ->through($fn5)
    ->run();
```

This makes the order of steps executed a lot clearer and gets rid of the annoying and ugly nesting of function calls.

Usage
-----

[](#usage)

```
use Sassnowski\Pipeline\Pipeline;

Pipeline::pipe(10)
    ->through(function ($i) { return $i + 10; })
    ->run();
// 11
```

Building reusable pipelines
---------------------------

[](#building-reusable-pipelines)

The `through($fn)` method does not change the existing Pipeline, but instead returns a new Pipeline instance that includes the next step. This enables you to reuse parts of a pipeline.

Since seeding the pipeline with an initial value goes against the idea of reusability, an additional method `build()` is defined. The `build` method does not initialize the pipeline with value. In this case the value has to be provided when calling the `run` method.

```
$pipeline1 = Pipeline::build()->through(function ($i) { return $i + 1 });

// Use the existing pipeline and simply add on additional steps.
$pipeline2 = $pipeline1->through(function ($i) { return $i * 10; });

// The initial pipeline remains unchanged.
$pipeline1->run(10); // 11

$pipeline2->run(10); // 110
```

Class-based steps
-----------------

[](#class-based-steps)

It is possible to use classes as steps instead of function. All the class has to do is implement the magic `__invoke` method.

```
class Add10
{
    function __invoke($i)
    {
        return $i + 10;
    }
}

// Somewhere else
Pipeline::pipe(10)
    ->through(new Add10)
    ->run();
// 20
```

This is useful if the execution of a step requires a lot of additional business logic that does not belong inside the object containing the Pipeline.

Exceptions
----------

[](#exceptions)

If a step is added to the pipeline that fails the `is_callable` check an `InvalidArgumentException` will be thrown.

```
Pipeline::pipe(10)->through(10); // InvalidArgumentException
```

If the `build` method was used to create a pipeline, the initial value has to be passed to then `run` method. Failing to do so will result in a `RuntimeException`.

```
Pipeline::build()->through(function ($i) { return $i + 10; })->run() // RuntimeException
```

Method aliases
--------------

[](#method-aliases)

In order to enable a more easily readable syntax when building a pipeline several method aliases for the `through` method exist.

- `firstThrough()`
- `andThen()`

```
Pipeline::pipe(10)
    ->firstThrough($fn1)
    ->andThen($fn2)
    ->andThen($fn3)
    ->run();
```

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~64 days

Total

2

Last Release

3598d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4502ad7427ecdff776d65d1ba32c9db22d0b9510a7cc959cab93fa0f5fa138de?d=identicon)[ksassnowski](/maintainers/ksassnowski)

---

Top Contributors

[![ksassnowski](https://avatars.githubusercontent.com/u/5139098?v=4)](https://github.com/ksassnowski "ksassnowski (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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