laravel: concurrent request

In Laravel, you can make concurrent request by using pool method of the HTTP Client of the Laravel.

$responses = Http::pool(function(Pool $pool) {
 return [
 $pool->get('http://example1.domain'),
 $pool->get('http://example2.domain'),
 $pool->get('http://example3.domain'),
 ];
});

// You can access the response 
return $responses[0]->ok() &&
 $responses[1]->ok() &&
 $responses[2]->ok();

// You can give them names as well
$responses = Http::pool(function(Pool $pool) {
 return [
 $pool->as('example1')->get('http://example1.domain'),
 $pool->as('examole2')->get('http://example2.domain'),
 $pool->as('example3')->get('http://example3.domain'),
 ];
});

// then access them with their names
return $responses['example1']->ok();