file_get_contents is not an asynchronous request. It is a 'blocking' request. You will not move past that line until it either succeeds of fails.
One way to make an async request in php is to use the ability of the operating system to fork a process. Another is to use sockets (and write to the socket without waiting on a response). A third is to use pthreads. These are all 'tricks' and not really async at all, however pthreads and forking will simulate an async request fairly well. The following code uses the fork technique.
<?php
private function request($url, $payload) {
$cmd = "curl -X POST -H 'Content-Type: application/json'";
$cmd.= " -d '" . $payload . "' " . "'" . $url . "'";
if (!$this->debug()) {
$cmd .= " > /dev/null 2>&1 &";
}
exec($cmd, $output, $exit);
return $exit == 0;
}
?>
This code was taken from a great article on the subject that can be found here:
https://segment.com/blog/how-to-make-async-requests-in-php/
The writer of the article does not discuss threading, but forking the process is simply using the OS to create your threads for you rather than doing it within your code. (sort of....)