Skip to content

Instantly share code, notes, and snippets.

@zencodex
Created October 25, 2018 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zencodex/53935fd8fa33a09695bf3769bb4e78c0 to your computer and use it in GitHub Desktop.
Save zencodex/53935fd8fa33a09695bf3769bb4e78c0 to your computer and use it in GitHub Desktop.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$client = new \GuzzleHttp\Client();
// $request = new \GuzzleHttp\Psr7\Request('GET', 'https://www.baidu.com');
$promises = [];
for ($i = 0; $i < 10; $i++) {
$promises = $client->requestAsync('GET', 'https://www.baidu.com')->then(function($response) use ($i) {
echo "$i => I completed" . PHP_EOL;
});
}
\GuzzleHttp\Promise\settle($promises)->wait();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment