Asynchronous Programming in PHP

A presentation at PHP Conference Japan 2021 by Lochemem Bruno Michael

Input-Output (otherwise known as I/O) is commonplace in daily programming but is quite arduous. PHP, though robust, offers sequential, blocking I/O solutions that require one to await completion of one task before starting another. Blocking I/O is somewhat inefficient, especially in modern applications that are computationally intensive in nature. Enter ReactPHP, a PHP-userland affable suite of technologies - complete with an event loop, a NodeJS-akin server, and Promises.

ReactPHP offers the advantages of non-blocking I/O - present in runtimes like Node.JS - to the PHP developers who use it. It provides, via the Reactor pattern, a means of efficiently running I/O operations in an event-driven domain.

My talk - titled Asynchronous Programming in PHP - is an attempt to distill asynchronous non-blocking I/O concepts for a PHP audience. The first part is an introduction to non-blocking I/O and describes the advantages of adopting event-driven approaches. The second part is a description of streams, promises, and the event loop. Lastly, the third and fourth parts - the respective focus points being usage and application of ReactPHP - conclude the session.