PHPackages                             phuria/pipolino - 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. phuria/pipolino

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

phuria/pipolino
===============

0.3.0(8y ago)31101MITPHPPHP &gt;=5.6.0

Since Mar 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/phuria/pipolino)[ Packagist](https://packagist.org/packages/phuria/pipolino)[ Docs](https://github.com/phuria/pipolino)[ RSS](/packages/phuria-pipolino/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Pipolino
========

[](#pipolino)

[![Build Status](https://camo.githubusercontent.com/3a59afed0ea786b3dcd58082a86b3e77fe9c6188cfa84a5ec6c802b0e8644a5a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f7068757269612f7069706f6c696e6f2e7376673f6d61784167653d33363030)](https://scrutinizer-ci.com/g/phuria/pipolino/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3b3676bd90fe94ff02262c02c7bc21c1f6ca02383a03d09879d24b1a6f4cd85e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7068757269612f7069706f6c696e6f2e7376673f6d61784167653d33363030)](https://scrutinizer-ci.com/g/phuria/pipolino/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/c0a4bc638ebf4fb8c6a549199bf9762a7d5609ead6b82fd90eb27bb0e03090cd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7068757269612f7069706f6c696e6f2e7376673f6d61784167653d33363030)](https://scrutinizer-ci.com/g/phuria/pipolino/?branch=master)[![Packagist](https://camo.githubusercontent.com/a84b71e399a245a8629e5081a74e4a35c7fe639a8cc651f7cfa945d257e19013/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068757269612f7069706f6c696e6f2e7376673f6d61784167653d33363030)](https://packagist.org/packages/phuria/pipolino)![license](https://camo.githubusercontent.com/0f9d85dd365959891a86e1906c95c41b3b61fb274d570c03e06a98bfb11733e1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068757269612f7069706f6c696e6f2e7376673f6d61784167653d323539323030303f7374796c653d666c61742d737175617265)![php](https://camo.githubusercontent.com/b011724bbacca84759f526aae2da4c3917841c00ef84d154a1120865097d881f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e362d626c75652e7376673f6d61784167653d32353932303030)

The package provides dispatcher that can be used to process one or more values in sequence. It is a combination of [thephpleague/pipeline](https://github.com/thephpleague/pipeline)and [PSR-7 middleware dispatcher (eg. Relay)](https://github.com/relayphp/Relay.Relay).

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

[](#installation)

```
composer require phuria/pipolino

```

Usage
-----

[](#usage)

```
$pipolino = (new Pipolino())
    ->addStage(function(callable $next, $payload) {
        return $next($payload * 2); // 20 * 2
    })
    ->addStage(function (callable $next, $payload) {
        return $next($payload + 1); // 40 + 1
    })
    ->addStage(function (callable $next, $payload) {
        return $next($payload / 10); // 41 / 10
    });

echo $pipolino->process(20); //output: 4.1
```

Immutable
---------

[](#immutable)

Pipolino are implemented as **immutable**. Any change on object (eg. add new stage) creates new object.

Stage objects
-------------

[](#stage-objects)

Object can be used as a stage. It must have only implemented `__invoke` method.

```
class CacheStage
{
    private $cache;

    public function __construct(CacheInterface $cache)
    {
        $this->cache = $cache;
    }

    public function __invoke(callable $next, $result, array $criteria)
    {
        $hash = sha1(serialize($criteria));

        if ($this->cache->has($hash)) {
            return $this->cache->get($hash);
        }

        $result = $next($result, $criteria);
        $this->cache->set($hash, $result, 3600);

        return $result;
    }
}
```

Many arguments
--------------

[](#many-arguments)

Pipolino (in contrast to pipeline) accepts any number of arguments to process.

```
$pipolino = (new Pipolino)
    ->addStage(function (callable $next, $result, array $options) {
        if (null === $result) {
            return $options['onNull'];
        }

        return $next($result, $context);
    })
    ->addStage(function (callable $next, $result, array $options) {
        $formatted = $next(number_format($result, 2).' '.$options['currency'])

        // Can be replaced with: "return $forrmated;",
        // however, should call $next().
        return $next($formatted, $options);
    });

$options = ['onNull' => '-', 'currency' => 'USD'];

echo $pipolino->process(null, $options); // output: -
echo $pipolino->process(10, $options); // output: 10.00 USD
```

Pipolino composite
------------------

[](#pipolino-composite)

Each pipolino can be used as stage. This allows for easy re-use pipolino.

```
$loadingProcess = (new Pipolino())
    ->add(new CheckCache())
    ->add(new LoadFromDB());

$showProcces = (new Pipolino())
    ->add(new JsonFormat())
    ->add($loadingProccess)
    ->add(new NullResult());
```

Default stage
-------------

[](#default-stage)

Default stage is last stage in pipolino, and does not accept `$next` callable as first argument. If you need to alter behavior of default stage (return first argument) call `Pipolino::withDefaultStage()` method.

```
$pipolino = (new Pipolino)
    ->addStage(function (callable $net, $i) {
        if (is_string($i)) {
            $i = (int) $i;
        }

        return $next($i);
    })
    ->addStage(function (callable $next, $i) {
        if (is_int($i)) {
            return $i % 2 ? 'even' : 'odd';
        }

        return $next($i);
    })
    ->withDefaultStage(function () {
        throw new \Exception('Unable to guess type.');
    });

echo $pipolino->process(2); // output: even
echo $pipolino->process('4'); // output: even
echo $pipolino->proccess(2.50); // throws exception
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

3229d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a021775fe34e57d70e7ce553ffb53a99f6f66d5c9f0d9534bb78e215c283b93?d=identicon)[phuria](/maintainers/phuria)

---

Top Contributors

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

---

Tags

dispatcherimmutablepipelineprocessingdispatcherpipeline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phuria-pipolino/health.svg)

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

###  Alternatives

[league/pipeline

A plug and play pipeline implementation.

1.0k16.0M74](/packages/league-pipeline)[stolz/assets

An ultra-simple-to-use assets management library

296519.2k8](/packages/stolz-assets)[contributte/event-dispatcher

Best event dispatcher / event manager / event emitter for Nette Framework

292.4M19](/packages/contributte-event-dispatcher)[aura/dispatcher

Creates objects from a factory and invokes methods using named parameters; also provides a trait for invoking closures and object methods with named parameters.

3695.0k3](/packages/aura-dispatcher)[imanghafoori/laravel-middlewarize

Use laravel middlewares on any method calls in your app

1134.5k1](/packages/imanghafoori-laravel-middlewarize)[aldemeery/onion

A layering mechanism for PHP applications.

5810.7k2](/packages/aldemeery-onion)

PHPackages © 2026

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