Why does PHP need asynchrony?

php dev.to

"The most dangerous phrase in the language is 'We've always done it this way.'" — Grace Hopper

PHP is one of the last major languages that still lacks built-in support for concurrent execution at the language level. Python has asyncio, JavaScript is natively built on an event loop, Go has goroutines, Kotlin has coroutines. PHP remains in the "one request — one process" paradigm, even though most real-world applications spend the majority of their time waiting for I/O (IO Bound).

The fragmentation problem ​

Today, asynchrony in PHP is implemented through extensions: Swoole, AMPHP, ReactPHP. Each creates its own ecosystem with incompatible APIs, its own database drivers, HTTP clients and servers.

This leads to critical problems:

  • Code duplication — each extension is forced to rewrite drivers for MySQL, PostgreSQL, Redis and other systems

  • Incompatibility — a library written for Swoole doesn't work with AMPHP, and vice versa

  • Limitations — extensions cannot make standard PHP functions (file_get_contents, fread, curl_exec) non-blocking, because they don't have access to the core

  • Barrier to entry — developers need to learn a separate ecosystem instead of using familiar tools

TrueAsync

True async/await, coroutines, and non-blocking I/O for PHP

favicon true-async.github.io

Source: dev.to

arrow_back Back to Tutorials