---
title: "The pipe operator in PHP 8.5"
url: https://daily.dev/posts/the-pipe-operator-in-php-8-5-ncqxtn0l7
source_url: https://stitcher.io/blog/pipe-operator-in-php-85
type: article
source: "stitcher.io"
published: 2025-07-04T06:16:30.950Z
updated: 2025-12-08T02:14:16.561Z
tags: ["functional-programming", "php"]
reading_time: 4
upvotes: 85
comments: 8
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The pipe operator in PHP 8.5

**[stitcher.io](https://daily.dev/sources/stitcher)** · 4 min read · 85 upvotes · 8 comments

## Summary

PHP 8.5 introduces the pipe operator (|>) that allows chaining function calls in a more readable way. Instead of deeply nested function calls or temporary variables, developers can pipe values through a series of transformations. The operator works with first-class callables for single-argument functions or closures for multi-argument functions. While currently requiring closures for complex operations, future partial function application support could make it even more concise.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://stitcher.io/blog/pipe-operator-in-php-85>

## Community discussion

Top comments from developers on daily.dev.

**@peter\_horvath** · 4 upvotes

> PHP should implement a proper String object, containing all the global string manipulation functions, and thus instead of a new syntax we could finally write modern OOP code.
> Instead of this:
> ```
> $output = $input
>     |> trim(...)
>     |> fn (string $string) => str_replace(' ', '-', $string)
>     |> fn (string $string) => str_replace(['.', '/', '…'], '', $string)
>     |> strtolower(...);
> ```
> We could have this
> ```
> $output = new String($input)
>   ->trim()
>   ->replace(' ', '-')
>   ->replace(['.', '/', '…'], '')
>   ->tolower()
>   ->__toString();
> ```
> Voila, much more readable. I know, it's a String...

**@mtariqsajid** · 3 upvotes

> this will be very weird to write this way |> php code

**@skeptiq** · 1 upvotes

> I love this! (I'm an fp programmer)

**@jack\_starborn** · 0 upvotes

> Example code with operations on string is not very convincing.   There are already many libraries that allow chaining of subsequent string transformation operations.
>
> If operations are not only on strings, then why not use this pipeline library?
> https://pipeline.thephpleague.com/

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#functional-programming](https://daily.dev/tags/functional-programming), [#php](https://daily.dev/tags/php)

[View this post on daily.dev](https://daily.dev/posts/the-pipe-operator-in-php-8-5-ncqxtn0l7)
