Skip to content
Programing

PHP 8.6 Alpha 1 & the Async Revolution with Io\Poll

Published: Duration: 7:20
0:00 0:00

Transcript

Host: Alex Chan Hey everyone, welcome back to Allur! I’m your host, Alex Chan. Today we are diving into something that literally just hit the wires, and if you’re a PHP developer, you’re going to want to sit up for this one. PHP 8.6 Alpha 1 was recently released. Now, I know what you’re thinking—"Alex, it’s an Alpha, I can’t use it in production yet!" And you’re right, you definitely shouldn’t. But this specific release is a massive milestone because it signals a huge shift in how PHP handles performance and functional programming. We’re talking about a native asynchronous revolution with the new `Io\Poll` API, plus some really cool syntax sugar like Partial Function Application and Typed Closures. It’s a glimpse into a future where PHP isn’t just a "request-response" language anymore, but a high-performance, event-driven powerhouse. To help me break down what this actually means for our daily dev lives, I’ve brought on a real expert in the field. Host: Alex Chan I am joined today by Marco Rossi. Marco is a core contributor to several async PHP projects and has been following the internals discussions for PHP 8.6 very closely. Marco, it is so great to have you on Allur! Guest: Marco Rossi Thanks, Alex! It’s great to be here. Yeah, 8.6 Alpha 1 is… honestly, it’s one of the most exciting Alphas I’ve seen in years. It feels like the internals team is finally tackling some of those "long-term" dreams we’ve had for the language. Host: Alex Chan Right? It feels like PHP is growing up in a very specific direction. So, let’s jump straight into the big one: `Io\Poll`. For years, if we wanted async PHP, we had to reach for things like ReactPHP or Amp, which are great, but they’re "userland" solutions. Now we’re seeing this native API. Why is this such a game-changer? Guest: Marco Rossi So, here’s the thing. When you use those libraries—which, full disclosure, I love—they have to jump through a lot of hoops. They’re essentially building a middleman between PHP and the operating system using stream wrappers. It works, but there’s an overhead. With `Io\Poll`, PHP is basically saying, "Okay, let’s talk to the OS directly." It uses `epoll` on Linux and `kqueue` on macOS and FreeBSD. These are the same underlying technologies that make Node.js or Go so fast at handling thousands of connections. Host: Alex Chan Interesting! So, instead of us constantly asking every single socket, "Hey, do you have data yet? How about now?", we just tell the OS, "Let me know when something happens," and then we wait? Guest: Marco Rossi Exactly! It’s non-blocking. You register your file descriptors—like a network socket or a database pipe—with this `Io\Poll` instance. Then, you just wait for a notification. It means the CPU isn’t spinning its wheels just checking if data is there. It can actually do work. For things like real-time chat servers, API gateways, or even just high-concurrency microservices, the performance gains are going to be… well, they’re going to be significant. Host: Alex Chan I love that. But I’ve heard some people ask, "Does this mean ReactPHP or Swoole are dead?" I’m guessing it’s actually the opposite? Guest: Marco Rossi Oh, totally the opposite! Actually, this makes their lives *easier*. Instead of those frameworks having to maintain complex, custom C extensions or heavy PHP-side loops to handle different OS polling, they can just swap their core engine to use `Io\Poll`. It’s like PHP is providing a high-performance engine block, and the frameworks can focus on building the rest of the car. It’s going to make the whole ecosystem faster and more stable. Host: Alex Chan That makes so much sense. It’s like the foundation is finally standardized. Now, moving away from the "under the hood" performance stuff, 8.6 is also bringing some features that actually change how we write our code day-to-day. Let’s talk about Partial Function Application, or PFA. I’ll admit, the first time I saw the proposal with the question marks, I was a bit confused. Guest: Marco Rossi (Laughs) Yeah, the `?` syntax! It looks a bit weird at first. So, Partial Function Application is basically a way to create a new, specialized function out of an old one by "pre-filling" some of the arguments. Host: Alex Chan Right, like if I have a function that takes three arguments, I can "lock in" the first two and get back a new function that only needs the third one? Guest: Marco Rossi Exactly. Imagine you have a general `log` function that takes a level, a prefix, and a message. Instead of writing `log('info', 'USER_SYSTEM', $msg)` every single time, you can use PFA to create a new function called `infoLog`. You just pass `?` for the message part. It’s super clean. Host: Alex Chan Wait, so how does that differ from currying? I feel like people use those terms interchangeably. Guest: Marco Rossi Yeah, they do, but they’re slightly different. Currying technically breaks a function into a *chain* of functions that each take exactly one argument. PFA is more practical for PHP—it’s just about fixing some arguments now and leaving the rest for later. It makes your code way more declarative. It’s less "how" to do something and more "what" you want the result to be. Host: Alex Chan I can see that being a huge win for readability, especially in complex pipelines. Speaking of clean code, let’s talk about Typed Closures. This feels like one of those things where you realize... "Wait, we didn't have this already?" Guest: Marco Rossi (Laughs) Honestly, right? We’ve had types for class methods and regular functions for ages. But closures—those anonymous functions we use in `array_map` or Laravel collections—they were kind of a "wild west" for a long time. In 8.6, you can finally strictly define the parameter types and the return type directly on the closure. Host: Alex Chan Which is a massive win for static analysis, right? I imagine PHPStan and Psalm are going to be very happy. Guest: Marco Rossi Oh, they’ll love it. But even for just… well, human sanity. When you’re looking at a piece of code six months later, seeing `fn(User $user): string => $user->name` is so much better than just `fn($user) => $user->name`. It prevents those "TypeError" surprises at 2 AM. It just brings that consistency we’ve been seeing since PHP 7.0 to every corner of the language. Host: Alex Chan It really feels like PHP 8.6 is trying to bridge the gap between being a "web language" and a "general-purpose high-performance language." When you look at the synergy of these features—the async performance of `Io\Poll` combined with the type-safety and functional elegance of PFA and Typed Closures—where do you see the ecosystem in two years? Guest: Marco Rossi I think we’re going to see a lot more "always-on" PHP applications. Right now, most PHP devs think in terms of "Request comes in, PHP wakes up, does work, PHP dies." With 8.6, I think we’ll see more long-running processes, more complex message queue workers that are actually efficient, and maybe even more people building things like custom WebSocket servers or even game backends in pure PHP without feeling like they’re fighting the language. Host: Alex Chan That is an incredibly exciting prospect. Marco, this has been so eye-opening. Before we wrap up, for the listeners who want to get their hands dirty with Alpha 1, what’s your advice? Guest: Marco Rossi Download it, but please, keep it on your local machine! (Laughs). Use Docker, spin up a container, and try to refactor some of your existing logic using Partial Function Application. See how it feels. And if you’re into network programming, try playing with `Io\Poll`. The Internals team really needs feedback right now to catch bugs before the stable release. Host: Alex Chan Perfect advice. Marco, thank you so much for joining me on Allur and breaking this down. Guest: Marco Rossi My pleasure, Alex! Thanks for having me. Host: Alex Chan And thank you all for tuning in! We covered a lot today—from the native async power of `Io\Poll` to the functional improvements that are making PHP cleaner and safer than ever. PHP 8.6 is shaping up to be a monumental release. If you want to see the code examples for what we discussed today, check out the show notes at allur-podcast.dev. Don't forget to subscribe and leave a review if you enjoyed the episode. I'm Alex Chan, and thanks for tuning into Allur. I’ll catch you in the next one!

Tags

backend php functional programming performance modernization concurrency