The Polling API Is PHP's Most Underrated Update

PHP 8.6 contains a quiet update that changes everything for high-concurrency networking.

While many developers debated generics, the Polling API passed through an RFC with very little noise. It received support from key figures like the creator of FrankenPHP and the author of Composer.

For years, PHP relied on stream_select(). This tool uses a system call from 1983. It has three major flaws:

  • It hits a limit of 1024 file descriptors on most systems.
  • It uses O(n) complexity, meaning performance drops as you add connections.
  • It lacks access to modern tools like epoll on Linux or kqueue on macOS.

This is why async libraries like AMPHP or ReactPHP required extra extensions like ext-uv to perform well. PHP lacked the native foundation for high-scale networking.

The Polling API fixes this hole.

It introduces the Io\Poll namespace. This API automatically picks the best backend for your system. It uses epoll on Linux, kqueue on macOS, and event ports on Solaris. You do not need to manage these details.

Here is how it works in practice:

You create a Context. You wrap a stream in a StreamPollHandle. You add it to the context with the events you want to watch. You call wait() to receive only the triggers that actually happened.

This is not a full event loop. It is a low-level primitive. It provides the plumbing that allows event loops to run faster and more reliably.

The real magic is internal. This API allows PHP core and extensions to share a unified interface. It enables:

  • Efficient signal handling for FrankenPHP.
  • Better event handling in PHP-FPM workers.
  • Standardized interfaces for sockets and curl.
  • High-performance edge-triggered modes.

People often say PHP cannot scale. For a long time, there was a technical reason for that claim. PHP did not have native access to the polling primitives used by Nginx or Go.

With PHP 8.6, that excuse is gone.

The best infrastructure changes are often invisible. You do not notice epoll. You only notice that a server handles ten thousand connections without breaking a sweat.

The Polling API is the unglamorous work that raises the ceiling for the entire ecosystem.

Source: https://dev.to/juststevemcd/the-polling-api-is-the-most-underrated-rfc-php-has-shipped-in-years-2d32