PHPackages                             aviator/pipe - 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. aviator/pipe

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

aviator/pipe
============

Chain callables using a simple wrapper class.

0.0.1(8y ago)31.9k↑288.2%[1 issues](https://github.com/danielsdeboer/pipe/issues)MITPHPPHP &gt;=7.0.0

Since Nov 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/danielsdeboer/pipe)[ Packagist](https://packagist.org/packages/aviator/pipe)[ Docs](https://github.com/danielsdeboer/pipe)[ RSS](/packages/aviator-pipe/feed)WikiDiscussions master Synced 1mo ago

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

Overview
--------

[](#overview)

PHP code can be frustratingly opaque, especially when dealing with nested functions. Why not chain those functions instead?

```
$filter = function ($item) { return $item === 'SOME'; };

// Offputting one-liner
echo implode('.', array_filter(explode('-', strtoupper(trim('    some-value'))), $filter))

// Multiple assignments
$value = '    some-value';
$value = trim($value);
$value = strtoupper($value);
$value = explode('-', $value);
$value = array_filter($value, $filter);
echo implode('.', $value);

// Easy to read pipe
echo take('    some-value')
    ->trim()
    ->strtoupper()
    ->explode('-', '$$')
    ->array_filter($filter)
    ->implode('.', '$$')
    ->get();

// prints 'SOME'
```

### Installation

[](#installation)

Via Composer:

```
composer require aviator/pipe

```

### Testing

[](#testing)

Via Composer:

```
composer test

```

### Usage

[](#usage)

Get a `Pipe` object:

```
$value = new Pipe('value');
$value = Pipe::take('value');
$value = take('value');
```

Then you can chain callables:

```
$value->pipe('strtoupper');
```

And get the mutated value:

```
echo $value->get();

// prints 'VALUE'
```

The pipe method is chainable:

```
echo Pipe::take('    value')
    ->pipe('trim')
    ->pipe('strtoupper')
    ->get();

// prints 'VALUE'
```

Pipe uses a magic `__call` to redirect other methods to the `pipe` method, so you don't have to use `pipe(...)` at all:

```
echo Pipe::take('    value')
    ->trim()
    ->strtoupper()
    ->get();

// prints 'VALUE'
```

### Arguments

[](#arguments)

You can use callables with arguments:

```
echo Pipe::take('value')
    ->str_repeat(3)
    ->strtoupper()
    ->get();

// prints 'VALUEVALUEVALUE'
```

`Pipe` will always pass the value you're mutating ('value' in the example above) as the first parameter.

This works most of the time, but since PHP has some unique parameter ordering, there are cases where it doesn't. In these cases you can use the placeholder, by default `$$`, to represent the mutating value.

For example, `implode()`:

```
echo Pipe::take(['some', 'array'])
    ->implode('.', '$$')
    ->get();

// prints 'some.array'
```

Because `implode()` takes the input value as its second parameter, we tell `Pipe` where to put it using '$$'. Then when called the value is swapped in.

### Closures

[](#closures)

You may pipe any callable, including a closure:

```
$closure = function ($item) { return $item . '-postfixed'; };

echo Pipe::take('value')
    ->pipe($closure)
    ->get();

// prints 'value-postfixed'
```

Other Stuff
-----------

[](#other-stuff)

### License

[](#license)

This package operates under the MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

### Thanks

[](#thanks)

This is largely based on [Sebastiaan Luca's idea](https://github.com/sebastiaanluca/laravel-helpers) and his `Pipe\Item` class.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity23

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

Unknown

Total

1

Last Release

3106d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpphp7pipephppipePHP7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aviator-pipe/health.svg)

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

###  Alternatives

[sebastiaanluca/php-pipe-operator

Method chaining (or fluent expressions) for any value using any method.

288467.7k2](/packages/sebastiaanluca-php-pipe-operator)[transprime-research/piper

PHP Pipe method execution with values from chained method executions

174.6k2](/packages/transprime-research-piper)

PHPackages © 2026

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