I’ve been trying to create an async request for a few days now, and I’m not succeeding either.. this is my code
require 'vendor/autoload.php';
use GuzzleHttpClient;
use GuzzleHttpPsr7Request;
$client= new Client();
$url="https://test.com?imei=123456789";
$request= new Request("GET", $url);
$promise = $client->sendAsync($request)->detach();
$promise->then(function ($response) {
echo 'I completed! ' . $response->getBody();
});
//$promise->wait();
echo "Continuing with other code...n";
die;
My composer.json
{
"name": "findy/findy",
"description": "A brief description of your project",
"require": {
"guzzlehttp/guzzle": "^7.8"
},
"autoload": {
"psr-4": {
"GuzzleHttp\": "vendor/guzzlehttp/guzzle/src/"
}
},
"minimum-stability": "stable"
}
When I run the code I get this error
Fatal error: Uncaught Error: Call to undefined method GuzzleHttpPromisePromise::detach()
Please help me