Introduction | piper | Spatie

 SPATIE

  Piper
========

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Piper](https://spatie.be/docs/piper/v1)  Introduction

 Version   v1

 Other versions for crawler [v1](https://spatie.be/docs/piper/v1)

  Introduction
- [ Introduction ](https://spatie.be/docs/piper/v1/introduction)
- [ Installation &amp; setup ](https://spatie.be/docs/piper/v1/installation-setup)
- [ Support us ](https://spatie.be/docs/piper/v1/support-us)
- [ Questions and issues ](https://spatie.be/docs/piper/v1/questions-issues)
- [ Changelog ](https://spatie.be/docs/piper/v1/changelog)
- [ About us ](https://spatie.be/docs/piper/v1/about-us)

Usage
-----

- [ Array functions ](https://spatie.be/docs/piper/v1/usage/array-functions)
- [ String functions ](https://spatie.be/docs/piper/v1/usage/string-functions)

 Piper
=======

Pipe operator-first PHP utility library
----------------------------------------

 [    Repository ](https://github.com/spatie/piper)

    0

    0

Introduction
------------

###  On this page

1. [ We have badges! ](#content-we-have-badges)

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 that work seamlessly with PHP 8.5's pipe operator.

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."
```

We have badges!
---------------------------------------------------------------------------------------------------

 [![Latest Version](https://img.shields.io/packagist/v/spatie/piper.svg?style=flat-square)](https://packagist.org/packages/spatie/piper) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/spatie/piper/blob/main/LICENSE.md) [![Tests](https://img.shields.io/github/actions/workflow/status/spatie/piper/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/spatie/piper/actions?query=workflow%3Arun-tests+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/spatie/piper.svg?style=flat-square)](https://packagist.org/packages/spatie/piper)

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
