Happy birthday ReactPHP – announcing the future of async with fibers!

Christian Lück Portrait Photo Christian Lück
on
tagged

ReactPHP – 10 years

Today marks ReactPHP’s 10th birthday. 🎉 To celebrate, we’re thrilled to announce the immediate availability of our all-new Async component using fibers in PHP 8.1+. By taking advantage of fibers, we’re making a big step forward for the future of async PHP and bringing new APIs that allow us to say ReactPHP has never been better!

Today we’re releasing several new major versions! We’ve been busy bees to not only support the latest PHP language features but also provide a smooth upgrade path for older versions:

You can check the ReactPHP changelog for all the details, but here’s the gist of why we’re enthusiastic to ring in the next generation of async PHP:

Async PHP with async & await

We’re especially excited about built-in support for fibers with the all-new Aync component. We believe this is a game-changer for the asynchronous PHP landscape. It provides a simple, composable, and consistent API for asynchronous programming in PHP. This makes it easy to write asynchronous code that is both super fast and easy to understand.

<?php

// $ composer require react/http react/async

use React\Http\Browser;
use function React\Async\await;

require __DIR__ . '/vendor/autoload.php';

$url = $argv[1] ?? 'https://reactphp.org/';
$browser = new Browser();

try {
    $response = await($browser->get($url));
    echo (string) $response->getBody();
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}

This example only covers the basics, but it’s easy to see how the new async() and await() functions make writing asynchronous PHP a breeze. They allow us to express the program flow in a way that we don’t have to deal with the intricacies of async execution anymore.

In other words, async programs will start to look no more complex than their synchronous counterparts. PHP 8.1+ provides built-in support for fibers which these functions use internally, so you don’t have to worry about the low-level details. What’s best, we went the extra mile to ensure the above example works across all PHP versions, so we can provide a smooth upgrade path to the future of async PHP for everybody.

Nextgen ReactPHP

The ReactPHP ecosystem is constantly growing and more and more projects and companies start seeing the advantages async PHP has to offer. Ten years ago, on 11th July 2012, the first beta release of ReactPHP was tagged. Fast forward to today, we’ve come a long way and ReactPHP is used in countless projects all over the world. With millions of downloads each month, ReactPHP has become one of the leading projects to build async PHP applications.

The new Async component marks a major milestone and is a game-changer for upcoming applications. This makes it easier than ever to develop async PHP applications and we believe this opens up new possibilities for the async PHP ecosystem and will allow ReactPHP to thrive. We will continue our long-term support (LTS) promise and will continue supporting the current version for the foreseeable future. On top of this, this release marks the starting point for future development in ReactPHP to explore newer language-level features and improved type safety. Hello ReactPHP v3, I’m sure we’ll hear more about this in the (near) future!

Thank you to everyone who has contributed to ReactPHP over the years, whether it’s been through code contributions, publishing blog posts and videos, helping with the documentation, answering questions on the issue tracker or chat, or just spreading the word about ReactPHP.

It’s been an amazing ride so far and we’re excited to see what the future brings! Happy birthday and here’s to another ten years of asynchronous PHP with ReactPHP! 🎉💥

We're Here to Help! Let's Tackle Your Problems Together.

Did you know we provide professional support for software projects? Book an appointment, you pay absolutely nothing for the first consultation.

Set Up a Free Call

We love feedback!

If you have anything to add, send a tweet to @another_clue.

We invite you to share our blog posts with friends and colleagues. All our blog posts can be shared freely under the permissive CC-BY license.

Email us if you think we should be working together on interesting projects.