Created
October 25, 2018 06:35
-
-
Save zencodex/53935fd8fa33a09695bf3769bb4e78c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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