PHP 8.6 Gains Native Async: 70+ Functions Turn Non‑Blocking
The True Async project plans to embed coroutine‑based, non‑blocking I/O directly into the PHP 8.6 core, offering an experimental v0.9.3 extension that supports over 70 native functions, a database pool, an HTTP server, and a low‑intrusion API that lets synchronous‑style code run concurrently, while warning that it is not yet production‑ready.
Why Async Matters
Traditional PHP‑FPM handles each request in an isolated process or thread, which isolates failures but incurs high overhead because the process spends most of its time idle waiting for I/O. The article compares this model to a restaurant where a server is dismissed after each table, illustrating the cost of context switches and resource consumption.
Synchronous vs Concurrent Execution
A serial PHP example shows three I/O calls (user API, database query, balance API) that together take 650 ms, with the CPU idle the whole time. The concurrent version uses spawn() to launch the three tasks simultaneously and await() to collect results, reducing total time to the slowest request (300 ms).
True Async Design Goals
True Async aims to bring coroutine and non‑blocking I/O into the PHP engine itself, targeting PHP 8.6. It implements a cooperative multitasking model: a single‑process, single‑thread runtime where a coroutine yields during I/O and the scheduler runs another ready coroutine. This preserves PHP’s simplicity while delivering concurrency.
Low‑Intrusion API
The core API revolves around four concepts:
spawn() : create a coroutine that can be paused and resumed.
await() : wait for a single coroutine to finish and retrieve its result.
Scope : manage a group of coroutines, allowing bulk cancellation on failure.
Safe cancellation : ensures no half‑finished data is left when a coroutine is aborted.
Example code (still written in a synchronous style) demonstrates launching three tasks and awaiting them with a timeout:
<?php
$page = spawn(fn() => file_get_contents($url));
$rows = spawn(fn() => $pdo->query($sql)->fetchAll());
$stats = spawn(fn() => file_get_contents($api));
[$html, $data, $meta] = await_all_or_fail([$page, $rows, $stats], timeout(2000));The total duration becomes the longest individual task rather than the sum of all three.
Core Advantages Over Existing Async Solutions
Unlike JavaScript or Python async/await, True Async avoids the "function coloring" problem: no async keyword is required, so ordinary synchronous code runs unchanged inside a coroutine. This is achieved by modifying the Zend core, I/O layer, database layer, and socket layer.
Coverage of Native Functions
Version v0.9.3 already makes more than 70 standard PHP functions non‑blocking inside coroutines while leaving their behavior unchanged outside, guaranteeing zero‑breakage for existing code. Supported categories include DNS resolution ( gethostbyname()), database drivers (PDO MySQL/PgSQL, MySQLi, native PostgreSQL), network functions (cURL, sockets, streams), file I/O ( fopen(), fread(), file_put_contents(), flock()), process execution ( proc_open(), exec(), shell_exec()), timers ( sleep(), usleep()), and isolated output buffers per coroutine. Functions such as opendir(), mkdir(), and some PDO drivers (Oracle, SQLite) are not yet supported.
Roadmap and Release Timeline
The project plans a stable v1.0 release in November 2026, aligned with PHP 8.6’s official launch. Milestones include PHP 8.6 Alpha 1 (released 2 July 2026), Beta 1 (mid‑August 2026), and the final release (19 November 2026). The inclusion of this feature in the final PHP 8.6 release remains uncertain until the later stages of the release cycle.
Developer Tooling
For early adopters, the true-async/ide-helper Composer package provides IDE autocompletion, inline documentation, and function stubs for PhpStorm, PHPStan, and Psalm, covering the async kernel, HTTP server, ClickHouse client, and more.
Conclusion
True Async represents a significant kernel‑level evolution for PHP, aiming to extend the language’s hallmark simplicity into the concurrent era. Although still experimental and not recommended for production, its roadmap and extensive function coverage make it a development to watch closely.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
