The MultiCurl class allows you to execute arbitrary code while waiting for responses.
Code can run between reading responses or before the first response.
For examples, see example.php and example-callback.php
To run the examples, run composer install.
Make public/sleep.php available via your web server and change the URL in bootstrap.php
This package can be installed via composer composer require rinu/multi-curl