mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-31 20:52:45 +00:00
Add additional logging to display progression
This commit is contained in:
@@ -5,10 +5,8 @@ use Curl\MultiCurl;
|
||||
|
||||
$multi_curl = new MultiCurl();
|
||||
|
||||
// Count the number of completed requests.
|
||||
$request_count = 0;
|
||||
$multi_curl->complete(function ($instance) use (&$request_count) {
|
||||
$request_count += 1;
|
||||
$multi_curl->beforeSend(function ($instance) {
|
||||
echo 'about to make request ' . $instance->id . ': "' . $instance->url . '".' . "\n";
|
||||
});
|
||||
|
||||
$multi_curl->success(function ($instance) use (&$request_count, $multi_curl) {
|
||||
@@ -19,6 +17,17 @@ $multi_curl->success(function ($instance) use (&$request_count, $multi_curl) {
|
||||
$multi_curl->stop();
|
||||
});
|
||||
|
||||
$multi_curl->error(function ($instance) {
|
||||
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
|
||||
});
|
||||
|
||||
// Count the number of completed requests.
|
||||
$request_count = 0;
|
||||
$multi_curl->complete(function ($instance) use (&$request_count) {
|
||||
echo 'call to "' . $instance->url . '" completed.' . "\n";
|
||||
$request_count += 1;
|
||||
});
|
||||
|
||||
$multi_curl->addGet('https://httpbin.org/delay/4');
|
||||
$multi_curl->addGet('https://httpbin.org/delay/1');
|
||||
$multi_curl->addGet('https://httpbin.org/delay/3');
|
||||
|
||||
Reference in New Issue
Block a user