cURL
is synchronous. So how do libraries like Guzzle send asynchronous web requests?
2 Answers
One of the Guzzle's transport handlers is CurlMultiHandler
that uses PHP's curl_multi_*
functions which allows for asynchronous transfers.
The requests are launched asynchronously and the function curl_multi_select()
allows Guzzle
to wait until one of the curl requests receives data and process it.

- 68,258
- 9
- 99
- 134
The Guzzle CurlMultiHander wraps PHP's builtin curl_multi_* function which essentially wrap the cURL Multi API
From the cURL documents:
To use the multi interface, you must first create a 'multi handle' with curl_multi_init. This handle is then used as input to all further curl_multi_* functions.
With a multi handle and the multi interface you can do several simultaneous transfers in parallel. Each single transfer is built up around an easy handle. You create all the easy handles you need, and setup the appropriate options for each easy handle using curl_easy_setopt.

- 1,989
- 11
- 16