PHPackages                             thlib/php-curl-multi-basic - 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. thlib/php-curl-multi-basic

ActiveLibrary

thlib/php-curl-multi-basic
==========================

Basic implementation of PHP curl\_multi. Minimal code, easy to configure, better memory management, no double loop, no 100% CPU usage error.

1.0.2(6y ago)181UnlicensePHPPHP &gt;=5.3.0

Since Apr 10Pushed 6y agoCompare

[ Source](https://github.com/thlib/php-curl-multi-basic)[ Packagist](https://packagist.org/packages/thlib/php-curl-multi-basic)[ RSS](/packages/thlib-php-curl-multi-basic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (1)

php curl multi basic example
============================

[](#php-curl-multi-basic-example)

Basic implementation of PHP curl multi

There are many implementations of curl multi, but the majority suffer from high CPU usage, inefficient memory management and run only after each request has finished instead of immediately.

Here is an example of how to avoid all of those issues without overloading it with functionality.

```
require 'CurlMulti.php';

$handles = [
    [
        // regular url
        CURLOPT_URL=>"http://example.com/",
        CURLOPT_FOLLOWLOCATION=>false,
        CURLOPT_WRITEFUNCTION=>function($ch, $body)
        {
            print $body;
            return strlen($body);
        }
    ],
     [
        // invalid url
        CURLOPT_URL=>"httpzzz://example.com/",
        CURLOPT_FOLLOWLOCATION=>false,
        CURLOPT_WRITEFUNCTION=>function($ch, $body)
        {
            print $body;
            return strlen($body);
        }
    ],
    [
        // url with a redirect
        CURLOPT_URL=>"http://www.php.net",
        CURLOPT_FOLLOWLOCATION=>false,
        CURLOPT_HEADERFUNCTION=>function($ch, $header)
        {
            print "header from http://www.php.net: ".$header;
            return strlen($header);
        },
        CURLOPT_WRITEFUNCTION=>function($ch, $body)
        {
            print $body;
            return strlen($body);
        }
    ]
];

//create the multiple cURL handle
$CurlMulti = new CurlMulti();

foreach($handles as $opts) {
    // create cURL resources
    $ch = curl_init();

    // set URL and other appropriate options
    curl_setopt_array($ch, $opts);

    // add the handle
    $CurlMulti->add($ch);
}

$statusCode = $CurlMulti->run(function($ch, $statusCode) {
    $info = curl_getinfo($ch);

    if ($statusCode !== CURLE_OK) {
        // handle the error somehow
        print "Curl handle error: ".curl_strerror($statusCode)." for ".$info['url'].PHP_EOL;
        return;
    }

    //$body = curl_multi_getcontent($ch);
    //print $body;
});
if ($statusCode !== CURLM_OK) {
    print "Curl multi handle error: ".curl_multi_strerror($statusCode)." for ".$info['url'].PHP_EOL;
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

2229d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/130741?v=4)[Timo Huovinen](/maintainers/TimoHuovinen)[@timohuovinen](https://github.com/timohuovinen)

---

Top Contributors

[![timohuovinen](https://avatars.githubusercontent.com/u/130741?v=4)](https://github.com/timohuovinen "timohuovinen (41 commits)")

### Embed Badge

![Health badge](/badges/thlib-php-curl-multi-basic/health.svg)

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

PHPackages © 2026

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