PHPackages                             pepsia/rolling-curl - 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. pepsia/rolling-curl

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

pepsia/rolling-curl
===================

A non blocking multi thread cURL library

v1.2(1y ago)1128MITPHPPHP &gt;=7.4

Since Sep 11Pushed 12mo ago2 watchersCompare

[ Source](https://github.com/FabsterSAS/RollingCurl)[ Packagist](https://packagist.org/packages/pepsia/rolling-curl)[ Docs](https://github.com/PEPSIASAS/RollingCurl)[ RSS](/packages/pepsia-rolling-curl/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

RollingCurlService
==================

[](#rollingcurlservice)

A non blocking multi thread cURL library

Overview
--------

[](#overview)

curl\_multi() makes it possible to handle multiple HTTP requests in parallel in PHP.
RollingCurl is a specific implementation of curl\_multi() that prevents from executing a whole stack of requests at once and having to wait for the slowest response.

RollingCurl starts by executing only a portion of a request stack and adding a new request each time a request has completed, while other requests are still running.

Features of this implementation:

- Add custom data to a request. This data is then available when a request has completed (e.g. the original url, or an ID)
- Set custom cURL options for all requests
- Add custom cURL options to the global options for a single request or replace the global options by custom options for a single request
- Write request response to file (local or distant using FTP)
- Custom rollingWindow (number of parallel requests)

Installation (via composer)
---------------------------

[](#installation-via-composer)

[Get composer](http://getcomposer.org/doc/00-intro.md) and run:

```
composer require pepsia/rolling-curl

```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
$urls = [
    'https://en.wikipedia.org/wiki/Moon',
    'https://en.wikipedia.org/wiki/Earth',
    'https://en.wikipedia.org/wiki/Saturn',
    'https://en.wikipedia.org/wiki/Jupiter',
    'https://en.wikipedia.org/wiki/Mars'
];

$rollingCurl = new \RollingCurlService\RollingCurl();

foreach ($urls as $key => $url) {
    $request = new \RollingCurlService\RollingCurlRequest($url);
    // RollingCurlRequest attributes is additional data that can be retrieved in curl callback
    $request->setAttributes([
        'requestId'   => $key // Some ID for the request
    ]);

    $rollingCurl->addRequest($request);
}

$curlResult = [];

$rollingCurl->execute(function ($output, $info, $request) use (& $curlResult)
{
    $requestAttributes = $request->getAttributes();
    // If request response was OK
    if ($info['http_code'] == 200) {
        $curlResult[$requestAttributes['requestId']] = $output;
    // If request response was KO
    } elseif ($info['http_code'] != 200) {
        $curlResult[$requestAttributes['requestId']] = 'KO response';
    }
});

var_dump($curlResult);
```

### Write request output to file

[](#write-request-output-to-file)

```
$urls = [
    'https://en.wikipedia.org/wiki/Moon',
    'https://en.wikipedia.org/wiki/Earth',
    'https://en.wikipedia.org/wiki/Saturn',
    'https://en.wikipedia.org/wiki/Jupiter',
    'https://en.wikipedia.org/wiki/Mars'
];

$rollingCurl = new \RollingCurlService\RollingCurl();

foreach ($urls as $key => $url) {
    $request = new \RollingCurlService\RollingCurlRequest($url);

    $request->setFileToWrite('/my/path/my_file.txt');
    // This also supports an FTP target: 'ftp://user:pass@host/my/path/my_video.mp4'

    $rollingCurl->addRequest($request);
}

$filesCount = 0;

$rollingCurl->execute(function ($output, $info, $request) use (& $filesCount)
{
    if ($info['http_code'] == 200) {
        $filesCount++;
        // If a file write path was provided => output was written directly to file
    }
});

var_dump($filesCount);
```

### Setting custom curl options

[](#setting-custom-curl-options)

For *every* request

```
$urls = [
    'https://en.wikipedia.org/wiki/Moon',
    'https://en.wikipedia.org/wiki/Earth',
    'https://en.wikipedia.org/wiki/Saturn',
    'https://en.wikipedia.org/wiki/Jupiter',
    'https://en.wikipedia.org/wiki/Mars'
];

$rollingCurl = new \RollingCurlService\RollingCurl();

foreach ($urls as $key => $url) {
    $request = new \RollingCurlService\RollingCurlRequest($url);
    $rollingCurl->addRequest($request);
}

// Set options for all requests by passing options array
$rollingCurl->setOptions([
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT   => 60,
]);

$rollingCurl->execute();
```

For *a single* request:

```
$urls = [
    'https://en.wikipedia.org/wiki/Moon'    => [CURLOPT_TIMEOUT => 15],
    'https://en.wikipedia.org/wiki/Earth'   => [CURLOPT_TIMEOUT => 5],
    'https://en.wikipedia.org/wiki/Saturn'  => [CURLOPT_TIMEOUT => 25],
    'https://en.wikipedia.org/wiki/Jupiter' => [CURLOPT_TIMEOUT => 10],
    'https://en.wikipedia.org/wiki/Mars'    => [CURLOPT_TIMEOUT => 15]
];

$rollingCurl = new \RollingCurlService\RollingCurl();

/*
    If setOptions() optional "addToGlobalOptions" param is set to TRUE the cURL options
    for that single request will be added to the global options instead of replacing them.
*/
foreach ($urls as $url => $options) {
    $request = new \RollingCurlService\RollingCurlRequest($url);
    $request->setOptions($options, TRUE);
    $rollingCurl->addRequest($request);
}

$rollingCurl->execute();
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance45

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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

Every ~776 days

Total

3

Last Release

521d ago

PHP version history (3 changes)v1.0PHP ^7.1.0

v1.1PHP &gt;=7.1.0

v1.2PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/187479506?v=4)[Pepsia](/maintainers/Pepsia)[@Pepsia](https://github.com/Pepsia)

---

Top Contributors

[![Rmy5](https://avatars.githubusercontent.com/u/30668074?v=4)](https://github.com/Rmy5 "Rmy5 (1 commits)")

---

Tags

httpasynchronouscurlparallelmultirequests

### Embed Badge

![Health badge](/badges/pepsia-rolling-curl/health.svg)

```
[![Health](https://phpackages.com/badges/pepsia-rolling-curl/health.svg)](https://phpackages.com/packages/pepsia-rolling-curl)
```

###  Alternatives

[chuyskywalker/rolling-curl

Rolling-Curl: A non-blocking, non-dos multi-curl library for PHP

207446.6k6](/packages/chuyskywalker-rolling-curl)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[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)[swlib/saber

Swoole coroutine HTTP client

985145.0k27](/packages/swlib-saber)[meabed/php-parallel-soap

Multi curl SoapClient that allow to perform multiple requests to SoapServer

4389.1k](/packages/meabed-php-parallel-soap)[voku/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

16183.9k1](/packages/voku-httpful)

PHPackages © 2026

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