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

Abandoned → [guzzlehttp/guzzle](/?search=guzzlehttp%2Fguzzle)ArchivedLibrary[HTTP &amp; Networking](/categories/http)

josantonius/curl
================

API Requests using the HTTP protocol through the Curl library.

1.1.7(3y ago)71234MITPHPPHP ^5.6 || ^7.0

Since Dec 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/josantonius/php-curl)[ Packagist](https://packagist.org/packages/josantonius/curl)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-curl/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (9)Dependencies (4)Versions (10)Used By (0)

PHP Curl library
================

[](#php-curl-library)

[![Latest Stable Version](https://camo.githubusercontent.com/1e7c26d369049a3b578470995f684524758d61f7ae5c48ca4361dae780559314/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f6375726c2f762f737461626c65)](https://packagist.org/packages/josantonius/curl)[![License](https://camo.githubusercontent.com/18bf99f1cf004b064efb13fed12ab5658fa5080e424c67077b26700711066aa7/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f6375726c2f6c6963656e7365)](LICENSE)

[Versión en español](README-ES.md)

API Requests using the HTTP protocol through the Curl library.

> This was a very basic option for using cURL. The use of [Guzzle](https://github.com/guzzle/guzzle) is recommended.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [Sponsor](#Sponsor)
- [License](#license)

---

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

[](#requirements)

This library is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher.

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

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP Curl library**, simply:

```
composer require Josantonius/Curl

```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require Josantonius/Curl --prefer-source

```

You can also **clone the complete repository** with Git:

```
git clone https://github.com/Josantonius/PHP-Curl.git

```

Or **install it manually**:

[Download Curl.php](https://raw.githubusercontent.com/Josantonius/PHP-Curl/master/src/Curl.php):

```
wget https://raw.githubusercontent.com/Josantonius/PHP-Curl/master/src/Curl.php

```

Available Methods
-----------------

[](#available-methods)

Available methods in this library:

### - Make request and get response website

[](#--make-request-and-get-response-website)

```
Curl::request($url, $params, $result);
```

AttributeDescriptionTypeRequiredDefault$urlUrl when get content.stringYesAttributeKeyDescriptionTypeRequiredDefault$paramsParameters.arrayNoarray()'referer'The referrer URL.stringNo'timeout'Timeout.intNo'agent'Useragent.stringNo'headers'HTTP headers.arrayNo'data'Parameters to send.arrayNo'type'Type of request.stringNoAttributeDescriptionTypeRequiredDefault$resultReturns result as array or object.stringNo'array'**\# Return** (array|object) → response

Quick Start
-----------

[](#quick-start)

To use this class with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\Curl\Curl;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/Curl.php';

use Josantonius\Curl\Curl;
```

Usage
-----

[](#usage)

Example of use for this library:

### - Send GET request and obtain response as array

[](#--send-get-request-and-obtain-response-as-array)

```
Curl::request('https://graph.facebook.com/zuck');
```

### - Send GET request and obtain response as object

[](#--send-get-request-and-obtain-response-as-object)

```
Curl::request('https://graph.facebook.com/zuck', false, 'object');
```

### - Send GET request with params and obtain response as array

[](#--send-get-request-with-params-and-obtain-response-as-array)

```
$data = [
    'timeout' => 10,
    'referer' => 'http://site.com',
];

Curl::request('https://graph.facebook.com/zuck', $data);
```

### - Send GET request with params and obtain response as object

[](#--send-get-request-with-params-and-obtain-response-as-object)

```
$data = [
    'timeout' => 10,
    'referer' => 'http://site.com',
];

Curl::request('https://graph.facebook.com/zuck', $data, 'object');
```

### - Send POST request and obtain response as array

[](#--send-post-request-and-obtain-response-as-array)

```
$data = [
    'type'    => 'post',
    'data'    => array('user' => '123456', 'password' => 'xxxxx'),
    'timeout' => 10,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data);
```

### - Send POST request and obtain response as object

[](#--send-post-request-and-obtain-response-as-object)

```
$data = [
    'type'    => 'post',
    'data'    => array('user' => '123456', 'password' => 'xxxxx'),
    'timeout' => 10,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data, 'object');
```

### - Send PUT request and obtain response as array

[](#--send-put-request-and-obtain-response-as-array)

```
$data = [
    'type'    => 'put',
    'data'    => array('email' => 'new@email.com'),
    'timeout' => 30,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data);
```

### - Send PUT request and obtain response as object

[](#--send-put-request-and-obtain-response-as-object)

```
$data = [
    'type'    => 'put',
    'data'    => array('email' => 'new@email.com'),
    'timeout' => 30,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data, 'object');
```

### - Send DELETE request and obtain response as array

[](#--send-delete-request-and-obtain-response-as-array)

```
$data = [

    'type'    => 'delete',
    'data'    => ['userId' => 10],
    'timeout' => 30,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data);
```

### - Send DELETE request and obtain response as object

[](#--send-delete-request-and-obtain-response-as-object)

```
$data = [
    'type'    => 'delete',
    'data'    => ['userId' => 10],
    'timeout' => 30,
    'referer' => 'http://' . $_SERVER['HTTP_HOST'],
    'headers' => [
        'Content-Type:application/json',
        'Authorization:0kdm3hzmb4h3cf',
    ],
];

Curl::request('https://graph.facebook.com/zuck', $data, 'object');
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/Josantonius/PHP-Curl.git

cd PHP-Curl

composer install

```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit

```

Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs

```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd

```

Run all previous tests:

```
composer tests

```

Sponsor
-------

[](#sponsor)

If this project helps you to reduce your development time, [you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work 😊

License
-------

[](#license)

This repository is licensed under the [MIT License](LICENSE).

Copyright © 2016-2022, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Recently: every ~441 days

Total

9

Last Release

1436d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.0

1.1.0PHP &gt;=5.6

1.1.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

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

---

Tags

curl-libraryhttp-protocolphpphp-curlhttpphpclientrestcurlhttp clientweb service

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.5k](/packages/ismaeltoe-osms)[zoonman/pixabay-php-api

PixabayClient is a PHP HTTP client library to access Pixabay's API

3355.9k](/packages/zoonman-pixabay-php-api)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

12261.2k1](/packages/e-moe-guzzle6-bundle)

PHPackages © 2026

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