Using RxPHP
Originally developed by Microsoft for the .NET platform, a set of libraries named ReactiveX (reactive extensions) is available at http://reactivex.io. ReactiveX allows us to write asynchronous and event-based programs using observable sequences. They do so by abstracting away low-level concerns such as non-blocking I/O, which we will talk about later. Over time, several programming languages made their own implementations of ReactiveX, following a nearly identical design pattern. The PHP implementation, named RxPHP, can be downloaded from https://github.com/ReactiveX/RxPHP:
Installing RxPHP
The RxPHP library is available as a Composer reactivex/rxphp
package. Assuming we already installed PHP and Composer, we can simply execute the following command in an empty directory:
composer require reactivex/rxphp
This should give us an output similar to the following one:
The output suggests installing react/event-loop
; we need to be sure to follow up on that by executing the following command...