A very nice post by Christopher Pitt about generators and how to use them to run code asynchronous.

https://medium.com/%2540assertchris/co-operative-php-multitasking-ce4ef52858a0