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

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

masroore/pipeline
=================

Pipeline pattern implementation

0.1.1(4y ago)0331BSD-2-ClausePHPPHP ^7.4|^8.0|^8.1

Since Mar 6Pushed 4y ago1 watchersCompare

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

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

### Pipeline

[](#pipeline)

A PHP package to build multi-staged workflows.

---

[![Author](https://camo.githubusercontent.com/f9009ebeb47e7742160e334cb430ee5c7d0201948a70981ca5cee41ab4b1af4c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d6173726f6f72652d7265642e7376673f7374796c653d706c6173746963)](https://twitter.com/masroore)[![Maintainer](https://camo.githubusercontent.com/e4d1a0bee52989145d5501d2935ce8b308fe9afa618308e9b08a3143948f8dc6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d61696e7461696e65722d406d6173726f6f72652d626c75652e7376673f7374796c653d706c6173746963)](https://twitter.com/masroore)

This package provides a pipeline pattern implementation.

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

[](#installation)

```
$ composer require masroore/pipeline
```

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 three parts:

- PipelineContextInterface
- PipelineStageInterface
- PipelineInterface

A pipeline consists of 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.

Concepts
--------

[](#concepts)

The package has two building blocks to create workflows : Pipeline and Stage and Step . A pipeline is a sequential collection of stages.

### The PipelineStageInterface Interface

[](#the-pipelinestageinterface-interface)

Stage is the unit of work which can be sequentially executed with other stages. To do that, we need to implement the `PipelineStageInterface` interface.

```
interface PipelineStageInterface
{
    public function id(): string;

    public function process(PipelineContextInterface $context): void;
}
```

To satisfy the interface we need to implement `process()`, `id()` methods in the target type. For e.g:

```
class TimesTwoStage implements PipelineStageInterface
{
    public function process(PipelineContextInterface $context): void
    {
        $val = (int) $context->getPayload();
        $val *= 2;
        $context->setPayload($val);
    }

    public function id(): string
    {
        return __CLASS__;
    }
}
```

The current stage receives a `PipelineContextInterface` value passed on by the previous stage. The `PipelineContextInterface` type provides a `shouldHalt()` method which can be used to halt pipeline execution.

Usage
-----

[](#usage)

```
use Kaiju\Pipeline\PipelineBuilder;
use Kaiju\Pipeline\PipelineContextInterface;
use Kaiju\Pipeline\PipelineStageInterface;

class Payload implements PipelineContextInterface
{
    private int $value;
    private bool $halt;

    public function __construct(int $value)
    {
        $this->value = $value;
        $this->halt = false;
    }

    public function shouldHalt(): bool
    {
        return $this->halt;
    }

    public function setHalt(bool $halt): void
    {
        $this->halt = $halt;
    }

    public function getPayload(): int
    {
        return $this->value;
    }

    public function setPayload($payload): void
    {
        $this->value = (int) $payload;
    }
}

class TimesTwoStage implements PipelineStageInterface
{
    public function process(PipelineContextInterface $context): void
    {
        $val = (int) $context->getPayload();
        $val *= 2;
        $context->setPayload($val);
    }

    public function id(): string
    {
        return __CLASS__;
    }
}

class AddOneStage implements PipelineStageInterface
{
    public function process(PipelineContextInterface $context): void
    {
        $val = (int) $context->getPayload();
        $val++;
        $context->setPayload($val);
        $context->setHalt(true);
    }

    public function id(): string
    {
        return __CLASS__;
    }
}

$payload = new Payload(10);
$builder = (new PipelineBuilder())
    ->addStage(new TimesTwoStage())
    ->addStage(new AddOneStage());
$pipeline = $builder->build();
$pipeline($payload);
echo 'Value is: ' . $payload->getPayload();
```

Check `examples` directory for more.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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 ~0 days

Total

2

Last Release

1525d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/200963?v=4)[Masroor Ehsan](/maintainers/masroore)[@masroore](https://github.com/masroore)

---

Top Contributors

[![masroore](https://avatars.githubusercontent.com/u/200963?v=4)](https://github.com/masroore "masroore (14 commits)")

---

Tags

workflowpipelinesequentialpipeline patternpipeline stagespipeline executionpipeline stage

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/pipeline

A plug and play pipeline implementation.

1.0k16.0M74](/packages/league-pipeline)[symfony/workflow

Provides tools for managing a workflow or finite state machine

62842.3M170](/packages/symfony-workflow)[yohang/finite

A simple PHP Finite State Machine

1.3k3.5M10](/packages/yohang-finite)[franzl/studio

Develop your Composer libraries with style

1.1k634.5k15](/packages/franzl-studio)[stolz/assets

An ultra-simple-to-use assets management library

296519.2k8](/packages/stolz-assets)[phpmentors/workflower

A BPMN 2.0 workflow engine for PHP

70652.9k4](/packages/phpmentors-workflower)

PHPackages © 2026

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