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

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

spatie/piper
============

A pipe operator-first PHP utility library for array and string manipulation

1.1.0(1mo ago)54658↑1300%MITPHP ^8.5

Since May 12Compare

[ Source](https://github.com/spatie/piper)[ Packagist](https://packagist.org/packages/spatie/piper)[ Docs](https://github.com/spatie/piper)[ GitHub Sponsors](https://github.com/Spatie)[ RSS](/packages/spatie-piper/feed)WikiDiscussions Synced 3w ago

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

 [   ![Logo for scotty](https://camo.githubusercontent.com/0e77832924b046739349da54c0ae913f8a4fbeaa8d83257fb22ed4121931e7dd/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f70697065722f68746d6c2f6c696768742e776562703f31373736383531333533)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=piper)Pipe operator-first utility library
===================================

[](#pipe-operator-first-utility-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/baf75937fdc9564069a4549dc2328a7f920dd6105f526eda9319a53ac67e82cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f70697065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/piper)[![GitHub Tests Action Status](https://github.com/spatie/piper/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/piper/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://github.com/spatie/piper/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/spatie/piper/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/71fb552375a73dc12b6337717bd65d703d3d4e014fcb7275bfd0c124d4876b68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f70697065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/piper)

Piper is a pipe operator-first PHP utility library for array and string manipulation. It ports Laravel's collection and string utility methods to standalone functions.

It comes with array helpers:

```
use function Spatie\Piper\Arr\{filter, map};

$popular = $posts
    |> filter(fn (Post $post) => $post->views > 1000)
    |> map(fn (Post $post) => $post->title);

// ["Claude Talk Small. Code Still Big.", …]
```

And string helpers:

```
use function Spatie\Piper\Str\{lower, replace};

'Hello, world!'
    |> lower()
    |> replace('world', 'Piper');

// "hello, Piper!"
```

Since all functions work with primitives, you can mix and match:

```
use function Spatie\Piper\Arr\{filter, join, map, values};
use function Spatie\Piper\Str\{prefix, suffix};

[1, 2, 3, 4, 5, 6]
    |> filter(fn (int $i) => $i % 2 === 0)
    |> map(fn (int $i) => pow($i, 2))
    |> values()
    |> join(', ', ', and ')
    |> prefix('The winning numbers are ')
    |> suffix('.');

// "The winning numbers are 4, 16, and 36."
```

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

[](#installation)

You can install the package via composer:

```
composer require spatie/piper
```

Documentation
-------------

[](#documentation)

All documentation is available [on our documentation site](https://spatie.be/docs/piper).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/709b9c61aacf09840eb29190cca3a2c0dbc1bca190be5032755b23471366ae93/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f70697065722e6a70673f743d31)](https://spatie.be/github-ad-click/piper)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source).

You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

Piper is a port of Laravel's collection &amp; string helpers. All methods, tests, and documentation examples are derived from the Laravel source. The porting strategy is described in [PORT.md](https://github.com/spatie/piper/blob/main/PORT.md).

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance93

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

3

Last Release

36d ago

Major Versions

0.0.1 → 1.0.02026-05-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Tags

spatiecollectionspipearraysPiper

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k430.2M1.5k](/packages/doctrine-collections)[spatie/laravel-package-tools

Tools for creating Laravel packages

952146.1M9.9k](/packages/spatie-laravel-package-tools)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k35.2M1.0k](/packages/spatie-laravel-data)[react/stream

Event-driven readable and writable streams for non-blocking I/O in ReactPHP

689146.0M213](/packages/react-stream)[spatie/macroable

A trait to dynamically add methods to a class

72964.4M76](/packages/spatie-macroable)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k19.8M70](/packages/spatie-regex)

PHPackages © 2026

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