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

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

roquie/pipeline
===============

A plug and play pipeline implementation.

0.1.1(10y ago)0452MITPHPPHP &gt;=5.6

Since Jun 25Pushed 10y ago2 watchersCompare

[ Source](https://github.com/roquie/pipeline)[ Packagist](https://packagist.org/packages/roquie/pipeline)[ RSS](/packages/roquie-pipeline/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (4)Used By (0)

Roquie\\Pipeline
================

[](#roquiepipeline)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/f0617606b7b2b1f6cc92964946eb70d73544ba02510fb28f2995c0d13a7d2b5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f717569652f706970656c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/roquie/pipeline)[![Total Downloads](https://camo.githubusercontent.com/eed37574e22b00b089b69218aa7a295d58a870125ba9cc095f711dfc7d499879/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f717569652f706970656c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/roquie/pipeline)[![Minimum PHP Version](https://camo.githubusercontent.com/86e7d829a466cacd5658a22073e27d49d39dac72cc18216ac4963ed5463c5bbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net/)

This package provides a pipeline pattern implementation.

Pipeline Pattern
----------------

[](#pipeline-pattern)

The pipeline pattern allows you to easily compose sequential stages by chaining stages.

In this particular implementation the interface consists of two parts:

- StageInterface
- PipelineInterface

A pipeline consists of zero, one, or multiple stages. A pipeline can process a payload. During the processing the payload will be passed to the first stage. From that moment on the resulting value is passed on from stage to stage.

In the simplest form, the execution chain can be represented as a foreach:

```
$result = $payload;

foreach ($stages as $stage) {
    $result = $stage->process($result);
}

return $result;
```

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

[](#immutability)

Pipelines are implemented as immutable stage chains. When you pipe a new stage, a new pipeline will be created with the added stage. This makes pipelines easy to reuse, and minimizes side-effects.

Simple Example
--------------

[](#simple-example)

```
use Roquie\Pipeline\Pipeline;
use Roquie\Pipeline\StageInterface;

class TimesTwoStage implements StageInterface
{
    public function process($payload)
    {
        return $payload * 2;
    }
}

class AddOneStage implements StageInterface
{
    public function process($payload)
    {
        return $payload + 1;
    }
}

$pipeline = (new Pipeline)
    ->pipe(new TimesTwoStage)
    ->pipe(new AddOneStage);

// Returns 21
$pipeline->process(10);
```

Re-usable Pipelines
-------------------

[](#re-usable-pipelines)

Because the PipelineInterface is an extension of the StageInterface pipelines can be re-used as stages. This creates a highly composable model to create complex execution patterns while keeping the cognitive load low.

For example, if we'd want to compose a pipeline to process API calls, we'd create something along these lines:

```
$processApiRequest = (new Pipeline)
    ->pipe(new ExecuteHttpRequest) // 2
    ->pipe(new ParseJsonResponse); // 3

$pipeline = (new Pipeline)
    ->pipe(new ConvertToPsr7Request) // 1
    ->pipe($processApiRequest) // (2,3)
    ->pipe(new ConvertToResponseDto); // 4

$pipeline->process(new DeleteBlogPost($postId));
```

Callable Stages
---------------

[](#callable-stages)

The `CallableStage` class is supplied to encapsulate parameters which satisfy the `callable` type hint. This class enables you to use any type of callable as a stage.

```
$pipeline = (new Pipeline)
    ->pipe(CallableStage::forCallable(function ($payload) {
        return $payload * 10;
    }));

// or

$pipeline = (new Pipeline)
    ->pipe(new CallableStage(function ($payload) {
        return $payload * 10;
    }));
```

Pipeline Builders
-----------------

[](#pipeline-builders)

Because pipelines themselves are immutable, pipeline builders are introduced to facilitate distributed composition of a pipeline.

The pipeline builders collect stages and allow you to create a pipeline at any given time.

```
use Roquie\Pipeline\PipelineBuilder;

// Prepare the builder
$pipelineBuilder = (new PipelineBuilder)
    ->add(new LogicalStage)
    ->add(new AnotherStage)
    ->add(new LastStage);

// Build the pipeline
$pipeline = $pipelineBuilder->build();
```

Exception handling
------------------

[](#exception-handling)

This package is completely transparent when dealing with exceptions. In no case will this package catch an exception or silence an error. Exceptions should be dealt with on a per-case basis. Either inside a **stage** or at the time the pipeline processes a payload.

```
$pipeline = (new Pipeline)
    ->pipe(CallableStage::forCallable(function () {
        throw new LogicException();
    });

try {
    $pipeline->process($payload);
} catch(LogicException $e) {
    // Handle the exception.
}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.8% 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 ~95 days

Total

2

Last Release

3920d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.5

0.1.1PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/35d8eff4a3e66b58f3e2af56fe948035469de1e19ac29c532d65c681955bbd18?d=identicon)[Roquie](/maintainers/Roquie)

---

Top Contributors

[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (41 commits)")[![roquie](https://avatars.githubusercontent.com/u/3214290?v=4)](https://github.com/roquie "roquie (7 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (2 commits)")[![dannyvankooten](https://avatars.githubusercontent.com/u/885856?v=4)](https://github.com/dannyvankooten "dannyvankooten (1 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (1 commits)")

---

Tags

patterndesign patternpipelinecompositionsequential

### Embed Badge

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

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

###  Alternatives

[league/pipeline

A plug and play pipeline implementation.

1.0k16.8M84](/packages/league-pipeline)[stolz/assets

An ultra-simple-to-use assets management library

289527.4k8](/packages/stolz-assets)[chefhasteeth/pipeline

18054.0k1](/packages/chefhasteeth-pipeline)[redeyeventures/geopattern

Generate beautiful SVG patterns.

11195.0k3](/packages/redeyeventures-geopattern)[getsolaris/laravel-make-service

A MVCS pattern create a service command for Laravel 5+

81169.8k](/packages/getsolaris-laravel-make-service)[functional-php/pattern-matching

Pattern matching for PHP with automatic destructuring.

8268.2k](/packages/functional-php-pattern-matching)

PHPackages © 2026

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