PHPackages                             phphd/pipeline-bundle - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. phphd/pipeline-bundle

ActiveSymfony-bundle[Queues &amp; Workers](/categories/queues)

phphd/pipeline-bundle
=====================

Chain of Responsibility on top of Symfony Messenger

1.0.0(2y ago)09.5k—3.6%[2 issues](https://github.com/phphd/pipeline-bundle/issues)MITPHPPHP &gt;=8.0.2

Since Jan 27Pushed 1y agoCompare

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

READMEChangelog (1)Dependencies (11)Versions (3)Used By (0)

PhdPipelineBundle
-----------------

[](#phdpipelinebundle)

🧰 Provides [Symfony Messenger](https://symfony.com/doc/current/messenger.html) middleware for basic per-bus pipelining. It enables streamlined chaining of the messages created by message handlers. For instance, when handler (hdl1) processes message (msg1), it creates a subsequent message (msg2), triggering the invocation of the next handler (hdl2), which may, in turn, produce yet another new message, and this cycle continues.

[![Codecov](https://camo.githubusercontent.com/8e043a35e9a873041674a7f5c6cf2a153c257330e66dfe913ec3280d5e4a51ec/68747470733a2f2f636f6465636f762e696f2f67682f70687068642f706970656c696e652d62756e646c652f67726170682f62616467652e7376673f746f6b656e3d475a525857595435355a)](https://codecov.io/gh/phphd/pipeline-bundle)[![Psalm coverage](https://camo.githubusercontent.com/7085d16df129024474a9734665d7492a8588fe9317597543695a2d1dcf899f35/68747470733a2f2f73686570686572642e6465762f6769746875622f70687068642f706970656c696e652d62756e646c652f636f7665726167652e737667)](https://shepherd.dev/github/phphd/pipeline-bundle)[![Psalm level](https://camo.githubusercontent.com/593b55db1821113bb005b10b4b4b1110ef2fb88ce1e2e7f4849c1a8ceaa5c044/68747470733a2f2f73686570686572642e6465762f6769746875622f70687068642f706970656c696e652d62756e646c652f6c6576656c2e737667)](https://shepherd.dev/github/phphd/pipeline-bundle)[![Build Status](https://camo.githubusercontent.com/7da41d4b8dd54574b6533f144ff7081756344b4b450ca51bec34e543bd891e36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70687068642f706970656c696e652d62756e646c652f63692e79616d6c3f6272616e63683d6d61696e)](https://github.com/phphd/pipeline-bundle/actions?query=branch%3Amain)[![Packagist Downloads](https://camo.githubusercontent.com/0c8f833ddd4e3ecf971996721dca12484316bc3bb88da98c6d9ea4da6ddfcc76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70687068642f706970656c696e652d62756e646c652e737667)](https://packagist.org/packages/phphd/pipeline-bundle)[![Licence](https://camo.githubusercontent.com/6d7f6ff3d05b5ddcdacf0313d70bff1e24a905dd9a53705b6e571b508c7fa933/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70687068642f706970656c696e652d62756e646c652e737667)](https://github.com/phphd/pipeline-bundle/blob/main/LICENSE)

Installation 📥
--------------

[](#installation-)

1. Install via composer

    ```
    composer require phphd/pipeline-bundle
    ```
2. Enable the bundle in the `bundles.php`

    ```
    PhPhD\PipelineBundle\PhdPipelineBundle::class => ['all' => true],
    ```

Configuration ⚒️
----------------

[](#configuration-️)

To leverage chain of pipelined handlers for your command/query buses, you should add `phd_pipeline.forward_chain` middleware to the list:

```
framework:
    messenger:
        buses:
            command.bus:
                middleware:
                    - doctrine_transaction
+                   - phd_pipeline.forward_chain
                    - validation
            query.bus:
                middleware:
+                   - phd_pipeline.forward_chain
                    - validation
```

Usage 🚀
-------

[](#usage-)

Consider having this *original message* that is initially dispatched to the message bus:

```
final readonly class CreateVacationRequestCommandDto
{
    public function __construct(
        public int $userId,
        public int $vacationTypeId,
        #[Assert\DateTime]
        public string $startDate,
        #[Assert\DateTime]
        public string $endDate,
    ) {
    }
}
```

Thy upfront message handler *returns a new message* that will be used for subsequent redispatch:

```
#[AsMessageHandler(bus: 'command.bus')]
final readonly class ConvertVacationRequestCommandHandler
{
    public function __invoke(CreateVacationRequestCommandDto $dto): CreateVacationRequestCommand
    {
        $employee = $this->employeeRepository->find($dto->userId);
        $vacationType = $this->vacationTypeRepository->find($dto->vacationTypeId);

        $vacationPeriod = VacationPeriod::fromStringDates($dto->startDate, $dto->endDate);

        return new CreateVacationRequestCommand($employee, $vacationType, $vacationPeriod);
    }
}
```

The *new created message* conveys basically the same business concept, but on the *higher level of abstraction* than initially. Thereof, instead of scalar types, it has business objects (e.g. `VacationType` entity instead of `$vacationTypeId` scalar). Basically, new class no longer merely represents the DTO. It now embodies the complete domain object.

You should add `#[NextForwarded]` *attribute to enable forwarding* of this new message to the next handler:

```
use PhPhD\Pipeline\NextForwarded;

#[NextForwarded]
final readonly class CreateVacationRequestCommand
{
    public function __construct(
        public Employee $employee,
        public VacationType $vacationType,
        public VacationPeriod $vacationPeriod,
    ) {
    }
}
```

> Messages lacking `#[NextForwarded]` attribute will not be forwarded. This attribute must be put on each message expected of redispatching.

Finally, one *ultimate handler* must implement the core business logic. It may or may not return a result to the calling code.

```
#[AsMessageHandler(bus: 'command.bus')]
final readonly class CreateVacationRequestHandler
{
    public function __invoke(CreateVacationRequestCommand $command)
    {
        // The core business logic that deals with domain entities rather than primitives...
    }
}
```

> You may chain as many message handlers as needed, even in a recursive manner, by returning an instance of the same class as the original message, provided that it has the forwarding attribute enabled.

Extended forwarding
-------------------

[](#extended-forwarding)

If you don't want to use the attribute on the message class, you don't have to. There could be some cases when you'd like to apply some dynamic configurations for `NextForwarded` instance. In such cases, you can return an instance of `NextForwarded` class right from the handler method:

```
#[AsMessageHandler(bus: 'command.bus')]
final readonly class ConvertVacationRequestCommandHandler
{
    /** @return NextForwarded */
    public function __invoke(CreateVacationRequestCommandDto $dto): NextForwarded
    {
        return new NextForwarded($this->createCommandFromDto($dto));
    }
}
```

The code above is no different from the one shown earlier.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

843d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41589422?v=4)[Yevhen Sidelnyk](/maintainers/rela589n)[@rela589n](https://github.com/rela589n)

---

Top Contributors

[![rela589n](https://avatars.githubusercontent.com/u/41589422?v=4)](https://github.com/rela589n "rela589n (9 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/storefront

Storefront for Shopware

684.2M148](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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