FTP client with RxPHP
For this example, let's imagine that we're running an FTP server where we want to perform a couple of operations. PHP has built-in support for FTP connections, so we don't need to install any extra libraries.
Our goal is to be able to do some basic operations with an FTP connection while utilizing what we know from RxPHP. When working with Observables, most of the time we've been using them in operator chains, but Observables can be used as asynchronous inputs or outputs as well. When returning a value from an asynchronous function, we'd usually use a Promise, but the same principles work with Observables too, and we can also benefit from chaining them.
Note that all FTP calls in PHP are blocking. Some functions have their non-blocking variants, such as functions to upload or download files, but others, such as functions that change or list a directory, are always blocking. For this reason, we'll stay only with their blocking variants. This way we can handle their correct...