PHPackages                             xicrow/php-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. xicrow/php-curl

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

xicrow/php-curl
===============

PHP wrapper and tools for cURL

1.0.0(3y ago)04MITPHPPHP ^7.4

Since Oct 5Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

PHP - cURL
==========

[](#php---curl)

PHP Wrapper and tools for cURL

---

**Note:** Early version still subject to major changes

---

Installation
------------

[](#installation)

The recommended way to install is through [Composer](https://getcomposer.org/).

```
composer require xicrow/php-curl
```

Or add directly to `composer.json`

```
{
    "require": {
        "xicrow/php-curl": "~1.0"
    }
}
```

Examples
--------

[](#examples)

### Request

[](#request)

Create new `Request`

```
$request = new Request();
```

Set cUrl options on `Request` construct

```
$request = new Request([
    CURLOPT_URL       => 'example.com',
    CURLOPT_USERAGENT => 'Mozilla/4.0',
    CURLOPT_TIMEOUT   => 5,
]);
```

Set cUrl options through `CurlOptions` instance on `Request`

```
$request->curlOptions()->set(CURLOPT_URL, 'example.com')->set(CURLOPT_USERAGENT, 'Mozilla/4.0');
$request->curlOptions()->set([
    CURLOPT_TIMEOUT        => 5,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_MAXREDIRS      => 3,
]);
```

### Response

[](#response)

Get `Response` from executing `Request`

```
$response = $request->execute();
```

Get body from `Response`

```
$response->body();
```

Get all headers from `Headers` instance on `Response`

```
$response->headers()->get();
```

Get specific headers from `Headers` instance on `Response`

```
$response->headers()->getHttpStatusCode();
$response->headers()->get('Http-Status-Code');
$response->headers()->get([
    'Http-Status-Code',
    'Http-Status-Message',
]);
```

### Batch

[](#batch)

Create new `Batch` with options

```
$batch = new Batch([
    'max_concurrent_requests' => 5,
]);
```

Add `Request` one at a time

```
$batch->addRequest(new Request());
```

Or add multiple `Request`s at once

```
$batch->addRequests([
    new Request(),
    new Request(),
    new Request(),
]);
```

Set `CurlOptions` on `Batch` which will merge with `CurlOptions` on `Request`

```
$batch->curlOptions()->set([
    CURLOPT_CUSTOMREQUEST  => 'GET',
    CURLOPT_PORT           => 80,
]);
```

Execute `Batch` and loop `Request`s and `Response`s
*Note: there are several ways to match `Request` to `Response` this is mainly for illustrative purpose*

```
$batch->execute();
foreach ($batch->getRequests() as $requestIndex => $request) {
    foreach ($batch->getResponses() as $responseIndex => $response) {
        // Skip if request and response index does not match
        if ($requestIndex != $responseIndex) {
            continue;
        }

        // ...
    }
}
```

TODO
----

[](#todo)

- Unit tests
- More utility methods for `CurlOptions`
- More utility methods for `Headers`
- Maybe refractor `CurlOptions` and `Headers` and how to get/set them

License
-------

[](#license)

Copyright © 2022 Jan Ebsen. Licensed under the MIT license.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Total

2

Last Release

1338d ago

Major Versions

0.1.0 → 1.0.02022-09-17

PHP version history (2 changes)0.1.0PHP ^7.0

1.0.0PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

[![xicrow](https://avatars.githubusercontent.com/u/1567795?v=4)](https://github.com/xicrow "xicrow (20 commits)")

---

Tags

phpcurlwrappertools

### Embed Badge

![Health badge](/badges/xicrow-php-curl/health.svg)

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

###  Alternatives

[stefangabos/zebra_curl

A high performance solution for making multiple HTTP requests concurrently, asynchronously from your PHP projects using cURL

21971.3k2](/packages/stefangabos-zebra-curl)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)

PHPackages © 2026

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