PHPackages                             h4cc/guzzle-rolling-batch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. h4cc/guzzle-rolling-batch

ActiveLibrary[HTTP &amp; Networking](/categories/http)

h4cc/guzzle-rolling-batch
=========================

A parallel executor for Guzzle Requests.

1.0(12y ago)56961MITPHP

Since Oct 17Pushed 12y ago2 watchersCompare

[ Source](https://github.com/h4cc/GuzzleRollingBatch)[ Packagist](https://packagist.org/packages/h4cc/guzzle-rolling-batch)[ RSS](/packages/h4cc-guzzle-rolling-batch/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

GuzzleRollingBatch
==================

[](#guzzlerollingbatch)

[![Build Status](https://camo.githubusercontent.com/72fccd4ad0d2a8ae3773d6f4bd2d1b03473fca2c0beeca34d936c29503703cb1/68747470733a2f2f7472617669732d63692e6f72672f683463632f47757a7a6c65526f6c6c696e6742617463682e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/h4cc/GuzzleRollingBatch)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/2ac4a4bcab4a5858917f41890af483fa9405559d2521ca9ef31493562827ee08/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f683463632f47757a7a6c65526f6c6c696e6742617463682f6261646765732f7175616c6974792d73636f72652e706e673f733d31323363623062623861306331616234386635613464386264653639353830333036343765656463)](https://scrutinizer-ci.com/g/h4cc/GuzzleRollingBatch/)[![SensioLabsInsight](https://camo.githubusercontent.com/ba0248c8353f18d381e2c325a37248da929b12e36216984f18b7884141ac1575/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61633034643164352d333365382d343034372d623266332d3739623938376137313636382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/ac04d1d5-33e8-4047-b2f3-79b987a71668)

This is a parallel Executor for guzzle that can process multiple requests in parallel. Instead of processing a batch of requests, there are two queues for requests and responses for dynamic handling of execution, adding new requests and processing responses.

Introduction
------------

[](#introduction)

When building a crawler with a batch system, there are multiple problems. Using batches wastes time when waiting for the result of the last request. There is no fully parallel processing of responses, adding and preparing new requests. When starting a batch, the result is more like a tiny DOS for the target site. To avoid all of these problems, RollingBatch was created.

Installation
------------

[](#installation)

Simply require the package by its name with composer:

```
$ php composer.phar require h4cc/guzzle-rolling-batch
```

Follow the 'dev-master' branch for latest dev version. But i recommend to use more stable version tags if available.

Usage
-----

[](#usage)

The RollingBatch consists of three parts. The RequestQueue, ResponseQueue and the RollingBatch. Lets have a look at each part.

### RequestQueue

[](#requestqueue)

New requests have to be added to the RequestQueue. From there, the RollingBatch fetches them with the 'next()' method.

In case you need a more flexible approach, implement your own RequestQueue.

### ResponseQueue

[](#responsequeue)

Received responses will be added to the ResponseQueue. From there they can be fetched and processed if needed.

Also, implementing your own ResponseQueue is an option for further functionality.

### RollingBatch

[](#rollingbatch)

The RollingBatch has some methods for controlling the process. Run 'execute()' to start new requests and execute started ones. Getting the current status can be fetched with 'countActive()' and 'isIdle()'.

A example for processing one or more request at once

```
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();
```

Be aware, that countActive() alone might not be enough as a predicate for loops etc.

It is also possible, to limit the current executed parallel requests. This can be done with 'setNumberParallel()'. Setting the value '0' will disable the limit. The number of parallel requests can also be reduced while running.

### Events

[](#events)

It is also possible to use the guzzle request events.

For example listening for exceptions.

```
use Guzzle\Common\Event;

$request->getEventDispatcher()->addListener('request.exception', function(Event $event) {
    throw $event['exception'];
});
```

For more events have a look here:

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4593d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ce109f0fc05421b5db21c1f35e9ff78be9bae38f5b6e3bd6121f2eb2417cf53?d=identicon)[h4cc](/maintainers/h4cc)

---

Top Contributors

[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (8 commits)")

---

Tags

httpclientcurlGuzzleparallel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/h4cc-guzzle-rolling-batch/health.svg)

```
[![Health](https://phpackages.com/badges/h4cc-guzzle-rolling-batch/health.svg)](https://phpackages.com/packages/h4cc-guzzle-rolling-batch)
```

###  Alternatives

[khr/php-mcurl-client

wrap curl client (http client) for PHP 5.3; using php multi curl, parallel request and write asynchronous code

71219.8k6](/packages/khr-php-mcurl-client)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[opgg/riotquest

RiotQuest, PHP RiotAPI client library that focused on multi request from OP.GG

172.6k](/packages/opgg-riotquest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
