Send asynchronous request without waiting the response using guzzle

If you don't care about the response, the following should do:

try {
    $this->guzzle->post('http://myurl.com/doNotWait', ['timeout' => 1]);
} catch (\GuzzleHttp\Exception\ConnectException $e) {
    // do nothing, the timeout exception is intended
}

So, here the request will take 1 sec and the code execution will continue.


To get it off the unanswered list:


Guzzle does not support "fire and forget" asynchronous requests without deep hacking.

The async methods are abstractions for Client::requestAsync(), which returns a promise. See https://github.com/guzzle/promises#synchronous-wait - calling Promise::wait() "is used to synchronously force a promise to complete".

Reference: https://github.com/guzzle/guzzle/issues/1429#issuecomment-197119452