PHP code example of h4cc / guzzle-rolling-batch
1. Go to this page and download the library: Download h4cc/guzzle-rolling-batch library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
h4cc / guzzle-rolling-batch example snippets
use Guzzle\Http\Message\Request;
use h4cc\GuzzleRollingBatch\RollingBatch;
$request = new Request('GET', 'http://example.com/');
$request->getCurlOptions()->set(CURLOPT_TIMEOUT_MS, 1000); // 1 Second
$batch = new RollingBatch();
$batch->getRequestQueue()->add($request);
do {
// Calling execute once will _not_ guarantee to finish all started requests.
$batch->execute();
} while (!$batch->isIdle());
$response = $batch->getResponseQueue()->next();
use Guzzle\Common\Event;
$request->getEventDispatcher()->addListener('request.exception', function(Event $event) {
throw $event['exception'];
});
bash
$ php composer.phar