PHPackages                             half2me/curlx - 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. half2me/curlx

Abandoned → [guzzlehttp/guzzle](/?search=guzzlehttp%2Fguzzle)Library[HTTP &amp; Networking](/categories/http)

half2me/curlx
=============

Easy to use wrapper for cUrl Multi

1.0.0(10y ago)33.6k3[1 issues](https://github.com/half2me/curlx/issues)[1 PRs](https://github.com/half2me/curlx/pulls)MITPHPPHP &gt;=5.6

Since Feb 12Pushed 7y ago1 watchersCompare

[ Source](https://github.com/half2me/curlx)[ Packagist](https://packagist.org/packages/half2me/curlx)[ Docs](https://github.com/half2me/curlx)[ RSS](/packages/half2me-curlx/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

CurlX
=====

[](#curlx)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/f96af19150979253eda2826376a151d27879fac72c6d8cd0c915eca20e9dd135/68747470733a2f2f7472617669732d63692e6f72672f68616c66326d652f6375726c782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/half2me/curlx)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/92cf0d9026b05f363b35d939ce3d15026c2fbd905719901aa4376e6c7d946bf2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f68616c66326d652f6375726c782f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/half2me/curlx/?branch=master)[![codecov.io](https://camo.githubusercontent.com/6a5f5d7d12fb4aeaa01bd26d50b4bea9247fa6511e941d0fe1edc1f0587b5bc6/68747470733a2f2f636f6465636f762e696f2f6769746875622f68616c66326d652f6375726c782f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/half2me/curlx?branch=master)[![Total Downloads](https://camo.githubusercontent.com/906bfebbcc58b76ef145e5fd3fd19f0de932a66e628976fc516e49a5c74a2e86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616c66326d652f6375726c782e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/half2me/curlx)[![Latest Stable Version](https://camo.githubusercontent.com/ad940fbb35005250e2e043fa847b4b5ce0e83748ca399a02877cd17145342957/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616c66326d652f6375726c782e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/half2me/curlx)[![Latest Unstable Version](https://camo.githubusercontent.com/31b6805e1504ec590b785a24d96ce55f6f5ac242e9117240ca3dad71709184cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f68616c66326d652f6375726c782e7376673f7374796c653d666c61742d737175617265266c6162656c3d756e737461626c65)](https://packagist.org/packages/half2me/curlx)
Curl X is a fork of [RollingCurlX](https://github.com/marcushat/RollingCurlX). At fist I only created this fork to make it installable via composer for a project I was working on. Now it is a modern, easy-to-use, awesome wrapper for cUrl Multi Handler. With Agents and Requests, take a look at how easy everything has become.

\####License MIT

#### Requirements

[](#requirements)

PHP 5.6+

Installing
==========

[](#installing)

Installing is easy with composer. Just do `composer require half2me/curlx:^1.0`

\##How to Use

First we initialize an agent with the maximum number of concurrent requests we want open at a time. All requests after this will be queued until one completes.

```
use CurlX\Agent;

$agent = new Agent(10);
```

Next we create/add a request to the queue

```
$request = $agent->newRequest('http://myurl.com'); // URL can optionally be set here
$request->url = 'http://myurl.com'; // or here
$request->timeout = 5000; // We can set different timeout values (in msec) for each request
$request->post_data = ['Agents' => 'AreCool']; // We can add post fields as arrays
$request->post_data = ['MoreAgents' => 'AreCooler']; // This will be appended to the post values already set
$request->headers = ['Content-type' => 'agent/xml', 'Authorization' => 'ninja-stuff']; // Headers can easily be set
$request->headers = ['Agent-type: Ninja']; // These will be appended to the header list
$request->options = ['CURLOPT_SOME_OPTION' => 'your-value']; // Advanced options can be set for cURL
$request->options = ['CURLOPT_SOME_OTHER_OPTION' => 'your-other-value']; // Chain these up, or add many in one array

// The Agent already has this request in his queue, so we don't need to do anything after modifying requests options.
```

Most of the values that can be set on individual Requests can also be set for an agent When an agent has these values set, any requests created by that agent, will have these parameters set; If we have many requests using similar headers, urls, or timeout values, we can set these once in the Agent, and use them in all of the requests. For example:

```
$agent->post_data = ['AllAgents' => 'AreCool'];
$request = $agent->newRequest();

echo $request->post_data['AllAgents']; // this will output 'AreCool'

// of course we can always overwrite this:
$request->post_data = ['AllAgents' => 'AreSuperDuperCool']; // This will overwrite that post value
```

Once we have our agent loaded up with requests

```
$request1 = $agent->newRequest();
$request2 = $agent->newRequest();
```

We can start executing them with:

```
$agent->execute();
```

As a request finishes, it will fire an event which we need to hook onto, before we start the agent. For this we need to register one or more callback functions with either the agent (to use the same for all requests) or we can register a separate callback function for each request.

```
$request1->addListener('myCallbackFunction'); // For a single request
$agent->addListener('myCallbackFunction'); // For all requests to use the same callback
// Note, this will only apply to requests made after the addListener() was called.

// You can use anonymous functions for callbacks like this:
$request->addListener(function(CurlX\RequestInterface $request) {
    // Each listener (or callback function) will upon request completion receieve
    // in the function parameter, the completed request object

    echo $request->response; // Response is stored here
    echo $request->http_code; // Get the http code of the reply
});
```

### Issues

[](#issues)

If you find any issues please let me know. Submit an issue or PR on github

Enjoy.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

3744d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2aaf39b42ce1fba12b8f6e84eaa0f68c8c912d6fe654bf2db574a21a17082fb8?d=identicon)[halftome](/maintainers/halftome)

---

Top Contributors

[![marcushat](https://avatars.githubusercontent.com/u/8149696?v=4)](https://github.com/marcushat "marcushat (4 commits)")[![daipratt](https://avatars.githubusercontent.com/u/85543?v=4)](https://github.com/daipratt "daipratt (1 commits)")

---

Tags

asynccurlmultiThread

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/half2me-curlx/health.svg)

```
[![Health](https://phpackages.com/badges/half2me-curlx/health.svg)](https://phpackages.com/packages/half2me-curlx)
```

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M384](/packages/php-http-curl-client)[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)[chuyskywalker/rolling-curl

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

207446.6k6](/packages/chuyskywalker-rolling-curl)[phpgt/fetch

Asynchronous HTTP client with promises.

3724.0k3](/packages/phpgt-fetch)[khr/react-curl

multi curl driver for reactphp.

1637.2k1](/packages/khr-react-curl)

PHPackages © 2026

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