Promises in PHP
We just released sabre/event 2.0 last week, featuring support for Promises.
So despite being interested in the pattern, it took a while for me to find a use-case where it actually made sense to deploy it.
Recently I was tasked to write a client for a webservice that would require:
- Lots and lots of HTTP request for many users.
- Some of which were required to happen in a specific order.
- Others could happen in parallel.
Using Promises was absolutely ideal here, and a lot of fun. So I added it to the sabre/event library.
I managed to compress the full concept into a single, relatively simple class, but it took a fair bit of step-through debugging to figure out what I did wrong at times.
The full documentation for it can be found on the website. I hope others have some use for it!