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

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

georgeff/pipeline
=================

Immutable pipeline builder

1.0.0(3mo ago)091MITPHPPHP ^8.2CI passing

Since Feb 6Pushed 3mo agoCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (0)

Pipeline
========

[](#pipeline)

An immutable pipeline library for PHP 8.2+.

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

[](#installation)

```
composer require georgeff/pipeline
```

Basic Usage
-----------

[](#basic-usage)

```
use Georgeff\Pipeline\Stage;
use Georgeff\Pipeline\Pipeline;

$pipeline = (new Pipeline())
    ->pipe(Stage::from(fn($payload) => $payload * 2))
    ->pipe(Stage::from(fn($payload) => $payload + 1));

$result = $pipeline->process(5); // 11
```

Stages
------

[](#stages)

All stages must implement `StageInterface`:

```
use Georgeff\Pipeline\StageInterface;

final class MultiplyStage implements StageInterface
{
    public function __construct(private readonly int $factor)
    {
    }

    public function __invoke(mixed $payload): mixed
    {
        return $payload * $this->factor;
    }
}

$pipeline = (new Pipeline())
    ->pipe(new MultiplyStage(2))
    ->pipe(new MultiplyStage(3));

$result = $pipeline->process(5); // 30
```

For simple transformations, use the `Stage` helper:

```
$pipeline = (new Pipeline())
    ->pipe(Stage::from(fn($payload) => $payload * 2));
```

Immutability
------------

[](#immutability)

The pipeline is immutable. Each call to `pipe()` returns a new instance:

```
$base = (new Pipeline())
    ->pipe(new ValidateOrder());

$adminPipeline = $base->pipe(new AdminCheck());
$userPipeline = $base->pipe(new UserCheck());

// $base remains unchanged
```

Factory
-------

[](#factory)

Build pipelines with initial stages:

```
use Georgeff\Pipeline\PipelineFactory;

$pipeline = PipelineFactory::build(
    new ValidateOrder(),
    new ProcessPayment(),
    new SendConfirmation()
);
```

Conditional Branching
---------------------

[](#conditional-branching)

Execute different stages based on a condition:

```
use Georgeff\Pipeline\ConditionalStage;

$pipeline = (new Pipeline())
    ->pipe(new ConditionalStage(
        fn($order) => $order->isPriority(),
        new PriorityProcessing(),
        new StandardProcessing()
    ));
```

The false branch is optional. If omitted, the payload passes through unchanged:

```
$pipeline = (new Pipeline())
    ->pipe(new ConditionalStage(
        fn($order) => $order->needsReview(),
        new FlagForReview()
    ));
```

Switch Branching
----------------

[](#switch-branching)

Select a stage based on a key:

```
use Georgeff\Pipeline\SwitchStage;

$pipeline = (new Pipeline())
    ->pipe(new SwitchStage(
        fn($order) => $order->getType(),
        [
            'digital' => new ProcessDigitalOrder(),
            'physical' => new ProcessPhysicalOrder(),
            'subscription' => new ProcessSubscription(),
        ],
        new ProcessUnknownOrder() // optional default
    ));
```

Early Termination
-----------------

[](#early-termination)

Implement `StoppableInterface` to halt pipeline execution:

```
use Georgeff\Pipeline\StageInterface;
use Georgeff\Pipeline\StoppableInterface;

final class ValidationStage implements StageInterface, StoppableInterface
{
    public function __invoke(mixed $payload): mixed
    {
        $payload->validate();
        return $payload;
    }

    public function shouldStop(mixed $payload): bool
    {
        return $payload->hasErrors();
    }
}
```

Nested Pipelines
----------------

[](#nested-pipelines)

Pipelines implement `StageInterface`, so they can be nested:

```
$validation = (new Pipeline())
    ->pipe(new ValidateFields())
    ->pipe(new ValidateBusinessRules());

$processing = (new Pipeline())
    ->pipe(new CalculateTotals())
    ->pipe(new ApplyDiscounts());

$pipeline = (new Pipeline())
    ->pipe($validation)
    ->pipe($processing)
    ->pipe(new SaveOrder());
```

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance81

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8147ce1d901e9fa2ec95d6408e5862025211f9ae60131e41fb115a5a0916ce4?d=identicon)[georgeff](/maintainers/georgeff)

---

Top Contributors

[![MikeGeorgeff](https://avatars.githubusercontent.com/u/6169468?v=4)](https://github.com/MikeGeorgeff "MikeGeorgeff (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[log1x/acf-composer

Create fields, blocks, option pages, and widgets using ACF Builder and Sage 10

493760.2k13](/packages/log1x-acf-composer)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[b13/menus

Easy and fast menus for TYPO3 Frontends

58534.7k1](/packages/b13-menus)[hfig/mapi

Pure PHP library for reading and manipulating Microsoft Outlook .msg messages (MAPI documents)

40420.9k2](/packages/hfig-mapi)

PHPackages © 2026

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