PHPackages                             programster/async-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. programster/async-curl

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

programster/async-curl
======================

A package to make it easier to send curl request asynchronously using \[curl\_multi\_exec\](https://secure.php.net/manual/en/function.curl-multi-exec.php).

1.1.1(5y ago)031MITPHPPHP &gt;= 7.0.0

Since Aug 18Pushed 5y agoCompare

[ Source](https://github.com/programster/package-async-curl)[ Packagist](https://packagist.org/packages/programster/async-curl)[ Docs](https://github.com/programster/curl-easier)[ RSS](/packages/programster-async-curl/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (0)

Async CURL Package
==================

[](#async-curl-package)

A package to make it easier to send curl request asynchronously using [curl\_multi\_exec](https://secure.php.net/manual/en/function.curl-multi-exec.php).

Examples
--------

[](#examples)

### Basic Batch Request

[](#basic-batch-request)

Here we will create 1,000 requests and send them all off. When all the requests have come back, we will process the responses.

```
$curlHandler = new Programster\AsyncCurl\BasicRequestHandler();

// create 1,000 requests to fire off asynchronously
for ($i=0; $i $i);
    $headers = array("header1" => "value1");

    $request = new \Programster\AsyncCurl\BasicRequest(
        "http://localhost:8081",
        Programster\AsyncCurl\Method::createPost(),
        $timeout=5, // seconds
        $params,
        $headers
    );

    $curlHandler->add($request);
}

// Fire the requests and get the responses
$curlHandler->run();

// get the responses array and do something with them
$responses = $curlHandler->getResponses();

foreach ($responses as $response)
{
    /* @var $response Programster\AsyncCurl\Response */
    // do something
}
```

### Handle Responses Asynchronously As They Come Back

[](#handle-responses-asynchronously-as-they-come-back)

Here we will create a 1,000 requests, but instead of waiting for all the responses to come back before processing them, we will process them immediately. This relies on us creating a "handler" callback that will handle the response.

```
$curlHandler = new Programster\AsyncCurl\AsyncRequestHandler();

// create 1,000 requests
for ($i=0; $i $i);
    $headers = array("header1" => "value1");

    // create the handler that will handle the response immediately after it comes back.
    $handler = function(Programster\AsyncCurl\Response $response) {
        if ($response->hadCurlError() === false)
        {
            print "Request went through ok: " . PHP_EOL;
            print "response code: " . $response->getHttpCode() . PHP_EOL;
            print "handling response " . $response->getResponseBody() . PHP_EOL;
        }
        else
        {
            print "There was an issue with the request: " . PHP_EOL;
            print "error code: " . $response->getCurlErrorCode() . PHP_EOL;
            print "error message: " . $response->getCurlErrorMessage() . PHP_EOL;
        }
    };

    $request = new \Programster\AsyncCurl\AsyncRequest(
        "http://localhost:8081",
        Programster\AsyncCurl\Method::createPost(),
        $timeout=5,
        $params,
        $headers,
        $handler
    );

    $curlHandler->add($request);
}

// Have the curl handler fire off the requests. Here it is non-blocking so you could do other
// things while the requests are being sent/recieved.
while ($curlHandler->getState() !== Programster\AsyncCurl\AsyncRequestHandler::SATE_COMPLETED)
{
    $curlHandler->run();
    // possibly do other things...?
    usleep(10); // don't waste CPU
}

// After getting out of the while loop, all requests will have had their handlers run against
// their response, but you can still get the responses from the handler should you desire...
$responses = $curlHandler->getResponses();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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 ~237 days

Total

3

Last Release

1987d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64a048ca8be761aced9419279975a21ef679b71c70d8263bc2fc413a87ad381c?d=identicon)[programster](/maintainers/programster)

---

Top Contributors

[![programster](https://avatars.githubusercontent.com/u/5709838?v=4)](https://github.com/programster "programster (12 commits)")

---

Tags

curl

### Embed Badge

![Health badge](/badges/programster-async-curl/health.svg)

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

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[kriswallsmith/buzz

Lightweight HTTP client

2.0k31.3M443](/packages/kriswallsmith-buzz)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[mashape/unirest-php

Unirest PHP

1.3k9.7M161](/packages/mashape-unirest-php)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

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