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

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

sylouuu/php-curl
================

Lightweight PHP cURL wrapper

0.8.1(10y ago)2719.5k↓50%111MITPHPPHP &gt;5.3.0

Since Apr 1Pushed 9y ago2 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (14)Used By (1)

PHP cURL
========

[](#php-curl)

[![Build Status](https://camo.githubusercontent.com/1fa880870164eb72afcad6997b362cb1131ceab87387636bb4382487d0f5e708/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f73796c6f7575752f7068702d6375726c2e7376673f7374796c653d666c6174)](https://travis-ci.org/sylouuu/php-curl)[![Version](https://camo.githubusercontent.com/88e3759573da00f65d2e60463becb637e77d162a7bda911b17898ced5272e066/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73796c6f7575752f7068702d6375726c2e7376673f7374796c653d666c6174)](https://packagist.org/packages/sylouuu/php-curl)[![CodeClimate](https://camo.githubusercontent.com/6b7255e96efc7463696e200a173fd1b66f7c4308fe4d0dd14e660a4d988fdb42/687474703a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f73796c6f7575752f7068702d6375726c2e7376673f7374796c653d666c6174)](https://codeclimate.com/github/sylouuu/php-curl)

Requirements
------------

[](#requirements)

- PHP &gt;= 5.4
- [cURL](http://php.net/manual/fr/book.curl.php/) library enabled

Install
-------

[](#install)

### Composer

[](#composer)

```
{
    "require": {
        "sylouuu/php-curl": "0.8.*"
    }
}
```

```
require_once './vendor/autoload.php';
```

Usage
-----

[](#usage)

```
// Namespace shortcut
use sylouuu\Curl\Method as Curl;

// Template
$request = new Curl\( string $url [, array $options ] );
```

Methods are:

- `Get()`
- `Head()`
- `Options()`
- `Post()`
- `Put()`
- `Patch()`
- `Delete()`

### Constructor `$options`

[](#constructor-options)

```
[
    'data' => [             // Data to send, available for `Post`, `Put` and `Patch`
        'foo' => 'bar'
    ],
    'headers' => [          // Additional headers (optional)
        'Authorization: foobar'
    ],
    'ssl' => '/cacert.pem', // Use it for SSL (optional)
    'is_payload' => true,   // `true` for sending a payload (JSON-encoded data, optional)
    'autoclose' => true     // Is the request must be automatically closed (optional)
]
```

### Public methods

[](#public-methods)

```
// Send a request
$request->send();

// HTTP status code
$request->getStatus();

// HTTP header
$request->getHeader();

// HTTP body response
$request->getResponse();

// Used cURL options
$request->getCurlOptions();

// Set a cURL option
$request->setCurlOption(CURLOPT_SOMETHING, $value);

// Manually close the handle (necessary when `autoclose => false` is used)
$request->close();
```

### Examples

[](#examples)

Basic:

```
// Namespace shortcut
use sylouuu\Curl\Method as Curl;

// Standard GET request
$request = new Curl\Get('http://domain.com');

// Send this request
$request->send();

echo $request->getResponse(); // body response
echo $request->getStatus(); // HTTP status code
```

Send a payload:

```
// Namespace shortcut
use sylouuu\Curl\Method as Curl;

// JSON-encoded POST request
$request = new Curl\Post($this->endpoint, [
    'data' => [
        'name' => 'foo',
        'email' => 'foo@domain.com'
    ],
    // With 'is_payload' => true
    // You don't have to json_encode() your array of data
    // Moreover, the appropriate headers will be set for you
    'is_payload' => true
]);

// Send this request
$request->send();

echo $request->getResponse(); // body response
echo $request->getStatus(); // HTTP status code
```

Manual closing:

```
// Namespace shortcut
use sylouuu\Curl\Method as Curl;

// Set `autoclose` option to `false`
$request = new Curl\Get('http://domain.com', [
    'autoclose' => false
]);

// Send this request
$request->send();

// Now you can retrieve a cURL info as the handle is still open
$request->getCurlInfo(CURLINFO_SOMETHING);

echo $request->getResponse();

// Manually close the handle
$request->close();
```

Tests
-----

[](#tests)

On project directory:

- `composer install` to retrieve `phpunit`
- `phpunit` to run tests

Changelog
---------

[](#changelog)

2015-08-25 - **0.8.1**

- fixed invalid content-length in case of no data provided

2015-07-03 - **0.8.0**

- added `is_payload` option to perform a request with JSON-encoded data
- fixed `ssl` option

2014-10-23 - **0.7.1**

- fixed `Post()` which didn't send data in some cases

2014-08-01 - **0.7.0** (BC break)

- moved from psr-0 autoload to psr-4
- added `Method` directory, then methods are now in `\sylouuu\Curl\Method\`

2014-05-30 - **0.6.1**

- removed exception when `data` option is not specified for `Post` `Put` and `Patch`

2014-05-22 - **0.6.0** (BC break)

- moved `url` option to the first constructor parameter

2014-05-20 - **0.5.0** (BC break)

- renamed repository from `php-rest-client` to `php-curl`
- refactored all code
- added `autoclose` option
- added the way to get/set cURL options
- added the way to get cURL info
- sources are now psr-2 compliant

2014-05-13 - **0.4.0** (BC break)

- renamed `RESTClient.class.php` to `RESTClient.php`
- moved `RESTClient.php` to `/src`
- moved `RESTClientTest.php` to `/tests`
- added `HEAD`, `OPTIONS` and `PATCH` support
- added `getHeader` method
- renamed `getJSON` to `getResponse`
- removed JSON validation
- added `sylouuu` namespace
- removed `gulp`

2014-05-09 - **0.3.0**

- added `ssl` option

2014-04-06 - **0.2.1**

- added exception if invalid JSON format returned

2014-04-04 - **0.2.0**

- new way to retrieve result
- added HTTP status code

2014-04-01 - **0.1.0**

- refactored class
- removed constructor parameter
- added unit tests

2014-03-24 - **0.0.2**

- added `$api_url` as a constructor parameter

2014-02-05 - **0.0.1**

- Initial release

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Recently: every ~113 days

Total

13

Last Release

3919d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ea3abfc29d7cdb6e94b09c22921c54cb6ad744d8b7f97d3e0646878cc714ad2?d=identicon)[sylouuu](/maintainers/sylouuu)

---

Tags

curlphp-libraryhttpcurl

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[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

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

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)[pear/http_request2

Provides an easy way to perform HTTP requests.

764.2M48](/packages/pear-http-request2)

PHPackages © 2026

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