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

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

10quality/php-curl
==================

Library (wrapper) that provides functionality for when doing requests using Curl. Perfect for when developing custom API connectivity or creating generic requests.

v1.0.2(5y ago)12.6kMITPHPPHP &gt;=5.4CI failing

Since Jun 23Pushed 3y ago3 watchersCompare

[ Source](https://github.com/10quality/php-curl)[ Packagist](https://packagist.org/packages/10quality/php-curl)[ Docs](https://github.com/10quality/php-curl)[ RSS](/packages/10quality-php-curl/feed)WikiDiscussions v1.0 Synced 4d ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Curl Wrapper (PHP)
==================

[](#curl-wrapper-php)

[![Latest Stable Version](https://camo.githubusercontent.com/cd6e8b9cb195225eee0bca0028e39b9b2c8662b5c45357f39842459d12b7a01a/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d6375726c2f762f737461626c65)](https://packagist.org/packages/10quality/php-curl)[![Total Downloads](https://camo.githubusercontent.com/3ffce56c68fb1fb5f3b1ea4c6255a23e6458517262f092e4d0f573cacdc6d8c7/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d6375726c2f646f776e6c6f616473)](https://packagist.org/packages/10quality/php-curl)[![License](https://camo.githubusercontent.com/d97937d8acb9c9ac032cd3c51fbd5e92b9fd6551797ea6bfbc766c68c2e37313/68747470733a2f2f706f7365722e707567782e6f72672f31307175616c6974792f7068702d6375726c2f6c6963656e7365)](https://packagist.org/packages/10quality/php-curl)

Library (wrapper) that provides functionality for when doing requests using Curl. Perfect for when developing custom API connectivity or creating generic requests.

Install
-------

[](#install)

```
composer require 10quality/php-curl
```

Usage
-----

[](#usage)

### Request call options

[](#request-call-options)

You can make your request call using the following options:

```
// With global `curl_request()`
$response = curl_request('http://my-api.com');

// With global `get_curl_contents()`
// --- Which is an alias of `curl_request()`
$response = get_curl_contents('http://my-api.com');

// With class `Curl`
$response = Curl::request('http://my-api.com');
```

### Parameters

[](#parameters)

Parameters sample:

```
$response = curl_request($url, $method, $data, $headers, $options);
```

ParameterTypeDescription`$url``string`Request URL.`$method``string`Request method (`GET` by default). Available options: **GET**, **POST**, **JPOST**, **JPUT**, **JGET**, **JDELETE**, **JUPDATE**, **JPATCH**. Json request is sent in those with the *J* prefix.`$data``array`The request data to send via query string, request body or both (Empty by default).`$headers``array`The list of request headers to add (Empty by default).`$options``array`The list of curl options to add (Empty by default).`$callable``mixed`Callable for when an unknown method is requested (null by default).#### Query string and post body

[](#query-string-and-post-body)

GET sample:

```
$response = curl_request(
    'http://my-api.com',
    'GET',
    [
        'action'    => 'get-countries',
        'format'    => 'xml',
    ]
);
```

POST sample:

```
$response = curl_request(
    'http://my-api.com',
    'POST',
    [
        'action'    => 'get-countries',
        'format'    => 'xml',
        'search'    => 'united',
        'limit'     => 5,
    ]
);
```

Using both:

Define `$data` array keys *query\_string* and *request\_body* to send some parameters as query string or request body. In the following example `action` and `format` will send as query string and `search` and `limit` as post body:

```
$response = curl_request(
    'http://my-api.com',
    'POST',
    [
        'query_string' => [
            'action'    => 'get-countries',
            'format'    => 'xml',
        ],
        'request_body' => [
            'search'    => 'united',
            'limit'     => 5,
        ],
    ]
);
```

The example below will generate the following request:

```
url:        http://my-api.com?action=get-countries&format=xml
post body:  search=united&limit=5
```

#### Headers

[](#headers)

The following example shows how to send headers:

```
$response = curl_request(
    'http://my-api.com',
    'GET',
    ['action' => 'get-countries'],
    [
        'Authorization: Bearer -token-',
        'Custom: Value',
    ]
);
```

#### Curl options

[](#curl-options)

The following example shows how to add curl options or override existing:

```
$response = curl_request(
    'http://my-api.com',
    'GET',
    ['action' => 'get-countries'],
    [],
    [
        CURLOPT_TIMEOUT         => 60,
        CURLOPT_RETURNTRANSFER  => 0,
        CURLOPT_USERAGENT       => 'Custom/Agent 007',
    ]
);
```

#### Custom request method using callables

[](#custom-request-method-using-callables)

If you need to make a special request to a different method from the ones supported, you can use the the `$callable` parameter as shown in the following sample:

```
$response = curl_request(
    'http://my-api.com',
    'XPOST',
    [],
    ['temperature' => 60, 'uptime' => 4564612131],
    [],// headers
    [],// options
    function($curl, $data) {
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'XPOST');
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
        return $curl;
    }
);
```

**NOTE:** The callable will receive `$curl` and `$data` as parameters and it is expecting to return the variable `$curl` back.

Guidelines
----------

[](#guidelines)

PSR-2 coding standards.

Copyright and License
---------------------

[](#copyright-and-license)

MIT License - (C) 2018 [10 Quality](https://www.10quality.com/).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

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

Total

4

Last Release

1227d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

curlwrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)[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)[minicli/curly

Simple Curl Client

14262.4k5](/packages/minicli-curly)[bca/curl

cURL wrapper for PHP applications.

1144.0k](/packages/bca-curl)

PHPackages © 2026

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