True Asynchronous inside PHP
Write sync. Run async.
Coroutines, non-blocking I/O, and structured concurrency, built into the language core. Write high-performance concurrent code with familiar functions and minimal changes.
// three coroutines run at the same time
$page = spawn(fn() => file_get_contents($url));
$rows = spawn(fn() => $pdo->query($sql)->fetchAll());
$stats = spawn(fn() => file_get_contents($api));
// wait for all three, cancel after 2s
[$html, $data, $meta] = await_all_or_fail(
[$page, $rows, $stats], timeout(2000));Production-oriented API
Coroutines
Lightweight coroutines for efficient concurrent execution. No colored async functions. Just do spawn() and go!
Non-blocking I/O
fread, fwrite, file_get_contents, ob_start, curl, MySQL, PostgreSQL. Regular PHP functions now work asynchronously without extra effort.
TrueAsync Server
Native HTTP/1.1, HTTP/2, and HTTP/3 web server written in C, running directly inside the PHP process.
Cooperative Cancellation
Simple and flexible API for coroutine cancellation. Scope::cancel().
Structured Concurrency
Control coroutine lifetime with Scope sandbox. Manage groups of coroutines via TaskGroup.
PDO Pool
Connection pooling built right into PDO. Automatic connection management for maximum performance.
Channel · ThreadPool
Data exchange between coroutines. Buffered and unbuffered channels for producer/consumer patterns. Cross-thread via ThreadChannel; parallel CPU tasks via Thread and ThreadPool.
Futures
Deferred results for asynchronous computations. Composition via await_all, await_first.
PHP Mobile
Android support at the PHP core level: an asynchronous runtime inside a native app via native-bridge.
Learn TrueAsync in practice
Hands-on guides, from your first coroutine to structured concurrency and the built-in server.
Coroutines
Your first look at coroutines: spawn() and concurrent execution.
Scope
Who owns a group of coroutines, waits for them, and cancels them together.
PDO Pool
Why coroutines can't share one PDO connection, and how the built-in pool solves it transparently.
Threads
spawn_thread and ThreadPool: real parallelism for CPU-bound work.
First Server
An HTTP server inside PHP: HttpServer, HttpServerConfig, and your first handler.
WebSocket
The recv loop, a chat room, send from other coroutines, and trySend against slow clients.