PHPackages                             transprime-research/piper - 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. transprime-research/piper

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

transprime-research/piper
=========================

PHP Pipe method execution with values from chained method executions

3.0.0(2y ago)174.6k↓100%[1 issues](https://github.com/transprime-research/piper/issues)2MITPHPPHP &gt;=7.4

Since Apr 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/transprime-research/piper)[ Packagist](https://packagist.org/packages/transprime-research/piper)[ Docs](https://transprime-research.github.io/piper/)[ RSS](/packages/transprime-research-piper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (8)Used By (2)

[![](https://github.com/transprime-research/assets/raw/master/piper/twitter_header_photo_2.png)](https://github.com/transprime-research/assets/blob/master/piper/twitter_header_photo_2.png)

[ ![Build Status](https://camo.githubusercontent.com/a5540b872ef61f47269d7085765a52b8461bf5503fd07324bbbc4fa4b5d78720/68747470733a2f2f7472617669732d63692e6f72672f7472616e737072696d652d72657365617263682f70697065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/transprime-research/piper)[ ![Latest Stable Version](https://camo.githubusercontent.com/2d4c61d31f87cfb71d5019552e22689f834c52d44fbf6e51e7dd90a10177bc12/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f70697065722f762f737461626c65)](https://packagist.org/packages/transprime-research/piper)[ ![Total Downloads](https://camo.githubusercontent.com/59c11bc16982d6b6dcf7825713087fff387743f8ad72e1f9d2d426674ed0f900/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f70697065722f646f776e6c6f616473)](https://packagist.org/packages/transprime-research/piper)[ ![Latest Unstable Version](https://camo.githubusercontent.com/91c40bc6203f9e149b9a02b011e9d3e99339d1f1efcc7a211357c14a771d6eb6/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f70697065722f762f756e737461626c65)](https://packagist.org/packages/transprime-research/piper)[ ![Latest Monthly Downloads](https://camo.githubusercontent.com/8957d7a450ba84cd63897a0c54e4f21d6f7f8575cf6d7ba573fece509801b728/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f70697065722f642f6d6f6e74686c79)](https://packagist.org/packages/transprime-research/piper) [ ![License](https://camo.githubusercontent.com/6da6086d20e4b9a44c3d98f06dd1f8d82cb022b73d6239b33ea4815e1e1d1e6b/68747470733a2f2f706f7365722e707567782e6f72672f7472616e737072696d652d72657365617263682f70697065722f6c6963656e7365)](https://packagist.org/packages/transprime-research/piper)

piper
=====

[](#piper)

PHP Pipe function execution with values from initial call like F#

> Pipe Like a PRO 🆗

Quick Usage
-----------

[](#quick-usage)

Let us take an array and do the following:

- flip the array to make the keys become the values and vice versa
- get the new keys
- change (the keys now) values to upper case
- take the exact item with `[0 => 'ADE']`

```
piper(['name' => 'ade', 'hobby' => 'coding'])
    ->to('array_flip')
    ->to('array_keys')
    ->to('array_map', fn($val) => strtoupper($val))
    ->to('array_intersect', [0 => 'ADE'])(); //returns ['ADE']
```

Or this in PHP 8.1+ Getting `['H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'L', 'D']` examples:

Use line - as in the line in Pipe-"line"

```
piper("Hello World")
    ->ln(
        htmlentities(...),
        str_split(...),
        [array_map(...), fn(string $part) => strtoupper($part)],
    );
```

Think about ductape on a pipe. Ducter allows such neat calls to your functions

```
ducter(
    "Hello World",
    htmlentities(...),
    str_split(...),
    [array_map(...), fn(string $part) => strtoupper($part)],
)
```

Call functions like an array:

```
_p("Hello World")
    [htmlentities(...)]
    [str_split(...)]
    [[array_map(...), strtoupper(...)]]()
```

How about Closure() on Closure

```
_p("Hello World")
    (htmlentities(...))
    (strtoupper(...))
    (str_split(...))
    (array_map(...), strtoupper(...))()
```

Cleaner with underscore `_`

```
_p("Hello World")
    ->_(htmlentities(...))
    ->_(str_split(...))
    ->_(array_map(...), strtoupper(...)));
```

Shortcut to `pipe()` is `p()`

```
_p("Hello World")
    ->p(htmlentities(...))
    ->p(str_split(...))
    ->p(array_map(...), strtoupper(...))()
```

PHP 7.4 `fn()` like

```
_p("Hello World")
    ->fn(htmlentities(...))
    ->fn(str_split(...))
    ->fn(array_map(...), strtoupper())
    ->fn()
```

Proxied call to globally available functions

```
_p("Hello World")
    ->htmlentities()
    ->str_split()
    ->array_map(strtoupper(...))()
```

Instead of:

```
array_intersect(
    array_map(
        fn($val) => strtoupper($val),
        array_keys(
            array_flip(['name' => 'ade', 'hobby' => 'coding'])
        )
    ),
    [0 => 'ADE']
); //returns ['ADE']
```

Or:

```
$arr = array_flip(['name' => 'ade', 'hobby' => 'coding']); // or array_values
$arr = array_keys($arr);
$arr = array_map(fn($val) => strtoupper($val), $arr);
$arr = array_intersect($arr, [0 => 'ADE']);

//$arr is ['ADE']
```

> PS: You can still use the old `function() { return v; }`, `fn()` is the new short arrow function in PHP 7.4+ See:

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

[](#installation)

- `composer require transprime-research/piper`

Requirement
-----------

[](#requirement)

Minimum Requirement

- PHP 7.2 +
- Composer

Other Usages
------------

[](#other-usages)

```
use Transprime\Piper\Piper;

// Normal
$piper = new Piper();
$piper->pipe(['AA'])->to('implode')->up();

// Better
$piper->on(['AA'])->to('implode')();
```

`piper()` function is a helper function. It is normally called like so:

```
// Nifty
piper('AA')->to('strtolower')();

// Good
Piper::on('AA')->to('strtolower')->up();

//Better
Piper::on('AA')->to('strtolower')();
```

Piper `piper()` function accepts a callable instance on the second parameter that would be immediately on the first parameter:

```
// test global method
piper('NAME', 'strtolower') // NAME becomes name
    ->to(fn($name) => ucfirst($name))
    ->up();
```

Also accepts a class with an accessible method name. Say we have this class:

```
class StrManipulator
{
    public function __invoke(string $value)
    {
        return $this->strToLower($value);
    }

    public static function strToLower(string $value)
    {
        return strtolower($value);
    }
}
```

`StrManipulator` class can be passed in with a method like so:

```
// test class method
piper('NAME', StrManipulator::class . '::strToLower')
    ->to(fn($name) => ucfirst($name))
    ->up();

// test array class and method
piper('NAME', [StrManipulator::class, 'strToLower'])
    ->to(fn($name) => ucfirst($name))
    ->up();
```

Even callable object is allowed like so:

```
// test class object
piper('NAME', new StrManipulator()) // A class that implements __invoke
    ->to(fn($name) => ucfirst($name))
    ->up();
```

Please see `\Transprime\Piper\Tests\PiperTest` for more examples.

Coming Soon
-----------

[](#coming-soon)

- Backward Pipe with `fro()` looking like:

```
piper('array_intersect', [0 => 'ADE'])
    ->fro('array_map', fn($val) => strtoupper($val))
    ->fro('array_keys')
    ->fro('array_flip')
    ->fro(['name' => 'ade', 'age' => 5])();
```

> Api implementation to be decided

Additional Information
----------------------

[](#additional-information)

See other packages in this series here:

-  \[A smart PHP if...elseif...else statement\]
-  \[A smarter Array now like an object\]
-  \[A smart PHP try...catch statement\]
-  \[A smart Carbon + Collection package\]
-  \[Jsonable Http Request(er) package with Collections response\]

Similar packages
----------------

[](#similar-packages)

-
-

Licence
-------

[](#licence)

MIT (See LICENCE file)

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~365 days

Total

6

Last Release

741d ago

Major Versions

1.0.0 → 2.0.02020-04-24

2.2.0 → 3.0.02024-04-27

PHP version history (2 changes)1.0.0PHP &gt;=7.4

2.1.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/364011bafbabff7b8c66b670b16ae372944dd4cc555531affffd901aae53d297?d=identicon)[omitobisam](/maintainers/omitobisam)

---

Top Contributors

[![omitobi](https://avatars.githubusercontent.com/u/16482234?v=4)](https://github.com/omitobi "omitobi (59 commits)")

---

Tags

operatorphppipephplaravelhelperspipefunctionalPiper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/transprime-research-piper/health.svg)

```
[![Health](https://phpackages.com/badges/transprime-research-piper/health.svg)](https://phpackages.com/packages/transprime-research-piper)
```

PHPackages © 2026

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