PHPackages                             pbergman/curl-multi - 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. pbergman/curl-multi

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

pbergman/curl-multi
===================

a simple curl wrapper for the multi handler

1.2.1(6y ago)021MITPHPPHP ^7.1

Since Dec 27Pushed 6y ago1 watchersCompare

[ Source](https://github.com/pbergman/curl-multi)[ Packagist](https://packagist.org/packages/pbergman/curl-multi)[ RSS](/packages/pbergman-curl-multi/feed)WikiDiscussions release/1.x Synced today

READMEChangelog (1)DependenciesVersions (5)Used By (0)

CurlMulti
---------

[](#curlmulti)

This a (light) abstract layer around the curl multi for handling asynchronously request.

The purpose of this library is to make it easier to handle to handle to responses but trying to keep as close to curl as possible. This should keep the api more stable, easier to work with (when familiar with curl) and less code around curl.

The provided request is therefor not more than an array like you wold register with `curl_setopt_array`. So urls, header etc. should be registered with the curl methods CURLOPT\_URL, CURLOPT\_WRITEHEADER, CURLOPT\_HTTPHEADER and rest could be found [here](http://php.net/manual/en/function.curl-setopt.php).

### example

[](#example)

```
use PBergman\CurlMulti\MultiHandler;
use PBergman\CurlMulti\Request;

$null = fopen("/dev/null", "w");
$handler = new MultiHandler(
    new Request([
        CURLOPT_URL => "http://httpstat.us/200?sleep=5000",
        CURLOPT_FILE  => $null,
    ]),
    new Request([
        CURLOPT_URL => "http://httpstat.us/404",
        CURLOPT_FILE  => $null,
    ])
);

try {
    foreach ($handler->getResponse() as $response) {
        printf(
            "request '%s' finished with code %d in %0.2fs\n",
            $response->getInfo(CURLINFO_EFFECTIVE_URL),
            $response->getInfo(CURLINFO_RESPONSE_CODE),
            $response->getInfo(CURLINFO_TOTAL_TIME)
        );
    }
} finally {
    // register cleanup
    $handler->close();
}

```

should give a output like:

```
request 'http://httpstat.us/404' finished with code 404 in 0.45s
request 'http://httpstat.us/200?sleep=5000' finished with code 200 in 5.49s

```

### public api

[](#public-api)

##### \_\_construct(RequestInterface ...$request): MultiHandler

[](#__constructrequestinterface-request-multihandler)

constructor of MultiHandler accepts request so you could register your request on creating a new instance.

```
(new MultiHandler(
    new Request([
        CURLOPT_URL => "http://httpstat.us/200?sleep=5000",
        CURLOPT_FILE  => $null,
    ]),
    new Request([
        CURLOPT_URL => "http://httpstat.us/404",
        CURLOPT_FILE  => $null,
    ])
))->wait();

```

##### setOptions(array $options) :bool

[](#setoptionsarray-options-bool)

set options for multi handler

##### addOption(int $key, $value) :bool

[](#addoptionint-key-value-bool)

set option for multi handler

##### add(RequestInterface $request): MultiHandler

[](#addrequestinterface-request-multihandler)

add request to defined instance.

##### defer(): void

[](#defer-void)

register the close function for shutdown.

##### init(): void

[](#init-void)

will setup the curl multi hadle, this will be called when creating a new instance and can be useful when the close method was called.

##### getResponse(): \\Generator|ResponseInterface\[\]

[](#getresponse-generatorresponseinterface)

returns a finished request and/or block until one is finished.

##### wait() : array||ResponseInterface\[\]

[](#wait--arrayresponseinterface)

wait till all request are finished

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~219 days

Total

4

Last Release

2399d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

1.1.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce73225a1c546feb93edc48c4b5d514a909aecceddc0fe0a021d4a42d2077e09?d=identicon)[pbergman](/maintainers/pbergman)

---

Top Contributors

[![activin-user](https://avatars.githubusercontent.com/u/69504579?v=4)](https://github.com/activin-user "activin-user (3 commits)")[![pbergman](https://avatars.githubusercontent.com/u/1193198?v=4)](https://github.com/pbergman "pbergman (1 commits)")

---

Tags

consolesymfonyarraycurltree

### Embed Badge

![Health badge](/badges/pbergman-curl-multi/health.svg)

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

###  Alternatives

[eightpoints/guzzle-bundle

Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony. Comes with easy and powerful configuration options and optional plugins.

45912.1M55](/packages/eightpoints-guzzle-bundle)[pbergman/tree-helper

A symfony console helper to print a tree

24469.4k4](/packages/pbergman-tree-helper)[zeroem/curl-bundle

Allows you to easily create and execute HTTP Requests with cURL

1323.5k](/packages/zeroem-curl-bundle)[fin1te/safecurl

A drop-in replacement for 'curl\_exec', designed to prevent SSRF attacks.

7325.7k](/packages/fin1te-safecurl)[mediamonks/rest-api-bundle

MediaMonks Rest API Symfony Bundle

1656.2k1](/packages/mediamonks-rest-api-bundle)

PHPackages © 2026

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