PHPackages                             dcarbone/curl-plus - 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. dcarbone/curl-plus

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

dcarbone/curl-plus
==================

Object wrapper for PHP's CURL Library

4.0.0(3y ago)2250.9k↓38.5%21Apache-2.0PHPPHP &gt;=8.0

Since Jan 27Pushed 3y ago2 watchersCompare

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

READMEChangelog (5)Dependencies (2)Versions (30)Used By (1)

curl-plus
=========

[](#curl-plus)

A simple wrapper around PHP's cURL implementation. It does not do anything magical, and is intended to be as simple as possible

[![Tests](https://github.com/dcarbone/curl-plus/actions/workflows/tests.yaml/badge.svg)](https://github.com/dcarbone/curl-plus/actions/workflows/tests.yaml)

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

[](#installation)

This lib is designed to be used with [Composer](https://getcomposer.org/)

"require" entry:

```
{
    "dcarbone/curl-plus" : "4.0.*"
}
```

CurlPlus Helper
---------------

[](#curlplus-helper)

To make executing and retrieving data from HTTP requests easier, I have created the [CURL](./src/CURL.php) helper class.

### Helper Basics:

[](#helper-basics)

All of the methods present below have a few default CURL options set, that you can override if needed:

- With the exception of HEAD and OPTIONS requests, all methods set `CURLOPT_RETURNTRANSFER` to true by default.
- ALL methods set `CURLOPT_FOLLOWLOCATION` to true by default.
- POST, PUT, and DELETE requests specify a default Request Content-Type header value of `application/x-www-form-urlencoded`
- POST, PUT, and DELETE requests allow specification of a request body. This may either be a string, or associative array of "param" =&gt; "value", or an object. It will be turned into a string utilizing [http\_build\_query](http://php.net/manual/en/function.http-build-query.php).
- ALL methods return an instance [CurlPlusResponse](./src/CurlPlusResponse.php)
- ALL methods allow overriding of CURLOPT and Request Header values used via optional array arguments. These will be merged with the defaults, with user-specified values receiving preference.

### Usage Basics

[](#usage-basics)

This class is as close as PHP gets to a "static" class. It is abstract, and therefore cannot be instantiated on its own, and is intended to be used as such:

```
use DCarbone\CurlPlus\CURL;

$response = CURL::get('http://www.gstatic.com/hostedimg/6ce955e0e2197bb6_large');

$image = imagecreatefromstring((string)$response);

header('Content-Type: image/jpeg');
imagepng($image);
imagedestroy($image);
```

The above will download photographic evidence of life saving tamales and output the image.

Check out the source of [CURL](./src/CURL.php) to get a better look at all available methods and arguments.

Using the client directly
-------------------------

[](#using-the-client-directly)

The most simple implementation of this class would be something like the following:

```
use DCarbone\CurlPlus\CURL;

$client = new CurlPlusClient(
    'http://my-url.etc/api',
    array(
        CURLOPT_RETURNTRANSFER => true,
    ));

// Returns \DCarbone\CurlPlus\CurlPlusResponse object
$response = $client->execute();

echo $response->responseBody."\n";
var_dump($response->responseHeaders);
var_dump($response->error);
```

The above will simply execute a GET request and store the response in memory, rather than in the output buffer.

### Constructor

[](#constructor)

The CurlPlusClient constructor takes 3 optional arguments:

- **$url** - string, the query endpoint
- **$curlOpts** - array, set of CURLOPT\_ values
- **$requestHeaders** - array, associative array of $param=&gt;$value strings that will be sent in the request

These are all optional parameters.

**Note**: If you set both the **$url** and CURLOPT\_URL properties on construction, the constructor will use to the CURLOPT\_URL value.

As stated above, all of those are optional arguments. You may simply construct the object with no params if you wish.

Post-construct, the methods:

```
// Set the URL you wish to query against, additionally you may also reset any existing curl opts
public function initialize($url, $reset = true) {}

// Accepts any options seen here: http://www.php.net//manual/en/function.curl-setopt.php
public function setCurlOpt($opt, $val) {}

// Accepts an associative array of Curl Opts
public function setCurlOpts(array $array) {}
```

...will probably be the ones you use the most often.

Check out the [CurlPlusClient source](./src/CurlPlusClient.php) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity79

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

Recently: every ~599 days

Total

29

Last Release

1370d ago

Major Versions

0.6.1 → 1.0.02014-10-28

1.0.2 → 2.0.02015-12-15

2.1.1 → 3.0.02016-09-13

3.0.1 → 4.0.02022-08-18

PHP version history (3 changes)0.1.0PHP &gt;=5.3.3

3.0.0PHP &gt;=5.4.0

4.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/385c0c0eae1b51f1e81ee464ff6bfb3cce32589ac252ca68cc3a8aec2e3ada14?d=identicon)[dcarbone](/maintainers/dcarbone)

---

Top Contributors

[![dcarbone](https://avatars.githubusercontent.com/u/1392439?v=4)](https://github.com/dcarbone "dcarbone (63 commits)")

---

Tags

phpcurl

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dcarbone-curl-plus/health.svg)

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

###  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)
