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

ActiveLibrary

exgalibas/curl
==============

php curl class

1.0(8y ago)216MITPHPPHP &gt;=7.0

Since Apr 10Pushed 7y agoCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Curl
====

[](#curl)

Curl is a wrapper of php cURL,chainable and simple

Installation
============

[](#installation)

```
composer require exgalibas/curl

```

Request Methods
===============

[](#request-methods)

GET|POST|OPTIONS|HEAD|PATCH|PUT|DELETE

Usage
=====

[](#usage)

### Basic

[](#basic)

```
$curl = new exgalibas\curl\Curl("http://example.com/index");
$curl->get(["name" => "exgalibas"]);

// check curl error
if (!$curl->error) {
    // output original curl response with header
    var_dump($curl->curlRawResponse);

    // output original curl response without header
    var_dump($curl->rawResponse);

    // output response processed by decoder
    var_dump($curl->response);

    // output real url
    var_dump($curl->url);

    // output request headers
    var_dump($curl->headers);

    // output curl options
    var_dump($curl->options);

    // output original curl response header
    var_dump($curl->rawResponseHeaders);

    // output processed response header
    var_dump($curl->responseHeaders);
} else {
    // output error
    var_dump($curl->error);

    // output error code
    var_dump($curl->errorCode);

    // output error message
    var_dump($curl->errorMessage);

    // output curl error
    var_dump($curl->curlError);

    // output curl error code
    var_dump($curl->curlErrorCode);

    // output curl error message
    var_dump($curl->curlErrorMessage);

    // output http error
    var_dump($curl->httpError);

    // output http status code
    var_dump($curl->httpStatusCode);

    // output http status
    var_dump($curl->httpStatus);
}

// another style
$curl = new curl\Curl();
$curl->url("http://example.com/index")->get(["name" => "exgalibas"]);

// transfer raw string
$curl->url("http://example.com/index")->get("a=b&c=d");
```

### Set Timeout

[](#set-timeout)

```
$curl->url("http://example.com/index")->expire(10)->get(["name" => "exgalibas"]);
```

### Set Retry

[](#set-retry)

```
$curl->url("http://example.com/index")->retry(4)->get(["name" => "exgalibas"]);
```

### Set Header

[](#set-header)

```
$curl->url("http://example.com/index")->header("Content-Type", "application/json")->post(["name" => "exgalibas"]);
```

### POST

[](#post)

```
$curl->url("http://example.com/index")->post(["name" => "exgalibas"]);

// multidimensional array
$curl->url("http://example.com/index")->post([
    "message" => [
        "name" => "exgalibas",
        "emial" => "exgalibas@gmail.com"
    ]
]);

// raw string
$curl->url("http://example.com/index")->post("abc"); //if server want to get the post string,do not use $_POST,file_get_contents("php://input") will work

// post file
$curl->url("http://example.com/index")->post([
    "file" => new CURLFile(__DIR__ . '/index.php')
]);

// another post file
$curl->url("http://example.com/index")->post([
    "file" => '@' . __DIR__ . '/index.php'
])

// post complicated data
$curl->url("http://example.com/index")->post([
    "name" => "exgalibas",
    "message" => [
        "age" => 18,
        "size" => 18
    ],
    "file" => [
        "file1" => new CURLFile(__DIR__ . '/index.php'),
        "file2" => '@' . __DIR__ . '/index1.php'
    ],
])

// post json data
$curl->url("http://example.com/index")->json()->post(["name" => "exgalibas"]);

// another post json data
$data = json_encode(["name" => "exgalibas"]);
$curl->url("http://example.com/index")->post($data);
```

### Processing Response

[](#processing-response)

There are two default decoders in the map, jsonDecoder and xmlDecoder,the pattern of map is \[regex string =&gt; decoder\].if you want to use default decoders,the Content-Type of response header must be the right type,like application/json,you can also specify other decoder or add new rules in the map.

```
// specify decoder
// $decoder must implements Decoder interface,$args will be transferred to $decoder
$curl->url("http://example.com/index")->decoder($decoder)->decoderArgs($args)->get();

// jsonDecoder
$args = [true, 12, JSON_BIGINT_AS_STRING]; //args will be used by json_decode()
$curl->url("http://example.com/index")->decoderArgs($args)->get();

// add new rules, it will search the right decoder by comparing the Content-Type of response and the regex of map automatically
$curl->url("http://example.com/index")->map('~^(?:text/|application/(?:atom\+|rss\+)?)xml~i', 'exgalibas\curl\XmlDecoder')->get();
```

### Todo

[](#todo)

add flexible mullti curl

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

2958d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b1634d29dd8a63e9d8469a4617f68188ddeb92624bcfb108107c6b360d9a65f?d=identicon)[exgalibas](/maintainers/exgalibas)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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