PHPackages                             ecfectus/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ecfectus/pipeline

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ecfectus/pipeline
=================

A Simple PHP 7 Pipeline class

016PHP

Since Feb 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ecfectus/pipeline)[ Packagist](https://packagist.org/packages/ecfectus/pipeline)[ RSS](/packages/ecfectus-pipeline/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Pipeline
========

[](#pipeline)

[![Build Status](https://camo.githubusercontent.com/7ec1164048211358a365c755b2e95b4fb26f94bb4185672bdb20cf564ba1aa6b/68747470733a2f2f7472617669732d63692e6f72672f65636665637475732f706970656c696e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ecfectus/pipeline)

A Simple PHP 7 Pipeline class.

The ecfectus pipeline is an un-opinionated sequential runner which takes pipes, and runs the given value(s) through each one, returning the end result.

Unlike other pipelines which are strict on number of arguments, the ecfectus pipeline will accept and return whatever you give to it.

If you give it 1 argument, that's what you get back, and the same is true for 6 arguments or more.

```
$pipeline new Ecfectus\Pipeline\Pipeline();
$pipeline->push(function($arg, callable $next){
    return $next($arg + 1);
});
$result = $pipeline(1);//$result = 2

$pipeline new Ecfectus\Pipeline\Pipeline();
$pipeline->push(function($arg, $arg2, callable $next){
    return $next($arg + 1, $arg2);
});
$result = $pipeline(1,3);//$result = [2, 3]
```

Whats more it will also tell you if the pipeline finished, or returned early from a pipe.

```
$pipeline new Ecfectus\Pipeline\Pipeline();
$pipeline->push(function($arg, callable $next){
    return $next($arg);
});
$pipeline->push(function($arg, callable $next){
    return $arg;
});
$pipeline->push(function($arg, callable $next){
    return $next($arg + 1);
});
$result = $pipeline(0);//$result = 0
$pipeline->finished();// == false as pipe 2 returned a result, not $next();
```

By design passed pipes MUST be `callable` and they are invoked in sequence. However that's not set in stone, you could if needed set your own resolver to resolve each pipe, perfect when using ioc containers, or to provide app specific syntax like `Class@method`.

```
$pipeline new Ecfectus\Pipeline\Pipeline();
$pipeline->setResolver(function($pipe){
    if(is_string($pipe)){
        //parse string, or fetch from ioc container
        $pipe = $someContainer->get($pipe);
    }
    if(is_callable($pipe)){
        return $pipe;
    }
    throw new InvalidArgumentException('Whoah, we could find that pipe!');
});
```

First or Last Argument Pipeline
-------------------------------

[](#first-or-last-argument-pipeline)

As described above what you give the pipeline, and then return from the pipes is the result given to you when completed.

However this flexibility isn't always desired, for example if using the pipeline as a middleware runner with request and response objects, you only want back the response.

This is where the `FirstArgumentPipeline` or `LastArgumentPipeline` classes come in.

```
$pipeline new Ecfectus\Pipeline\FirstArgumentPipeline();
$pipeline->push(function($arg, $arg2, callable $next){
    return $next($arg + 1, $arg2);
});
$result = $pipeline(0,0);//$result = 1

$pipeline new Ecfectus\Pipeline\LastArgumentPipeline();
$pipeline->push(function($arg, $arg2, callable $next){
    return $next($arg + 1, $arg2 + 2);
});
$result = $pipeline(0,0);//$result = 2
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![leemason](https://avatars.githubusercontent.com/u/1238646?v=4)](https://github.com/leemason "leemason (8 commits)")

### Embed Badge

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

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

PHPackages © 2026

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