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

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

adrii/curl-helper
=================

CurlHelper is a streamlined PHP utility for easy cURL usage, supporting GET, POST, PUT, and DELETE methods. It simplifies HTTP requests by offering straightforward options and header settings, making web API interactions more accessible and efficient.

1.9.3(2y ago)117.9k↓46.9%14MITPHPPHP ^7.4 || ^8.0

Since Oct 9Pushed 2y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (25)Used By (4)

CurlHelper
==========

[](#curlhelper)

*Original author: [Adrii](https://github.com/AdrianVillamayor)*

[![Test](https://github.com/AdrianVillamayor/CurlHelper/actions/workflows/php.yml/badge.svg)](https://github.com/AdrianVillamayor/CurlHelper/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/a2dcf638220fa8f4c82d1922bb5dbbe48552da7f14abf54be570b3023d16cd8a/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61647269692f6375726c2d68656c7065722e737667)](https://packagist.org/packages/adrii/curl-helper)[![Total Downloads](https://camo.githubusercontent.com/95cd49725435b4e8d881a5a46b83c77cae4095d5e6c79358ceafdbca574e4303/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61647269692f6375726c2d68656c7065722e737667)](https://packagist.org/packages/adrii/curl-helper)[![License](https://camo.githubusercontent.com/1a914807da0949b1213abe3bcbb9399ad510de2dd51134485ceec68203501042/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61647269692f6375726c2d68656c7065722e737667)](https://packagist.org/packages/adrii/curl-helper)

`CurlHelper` is a streamlined PHP utility for easy cURL usage, supporting GET, POST, PUT, and DELETE methods. It simplifies HTTP requests by offering straightforward options and header settings, making web API interactions more accessible and efficient.

Features
--------

[](#features)

- **Versatile HTTP Support**: GET, POST, PUT, and DELETE methods are all supported, catering to a wide range of API interactions.
- **Header &amp; Option Customization**: Effortlessly configure request headers and cURL options to meet the precise needs of every API call.
- **File Uploads**: Simplified multipart/form-data handling makes file uploads a breeze.
- **Data Flexibility**: Easily switch between raw and array data inputs, with automatic content type handling for JSON and form-urlencoded data.
- **Debug Mode**: Activate detailed logging for troubleshooting and optimization, gaining insight into request and response cycles.

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

[](#requirements)

- PHP 7.4 or higher
- cURL extension enabled in PHP

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

[](#installation)

You can copy the `CurlHelper` class into your project, or preferably, autoload it using [Composer](https://getcomposer.org/).

```
composer require adrii/curl-helper
```

### Composer

[](#composer)

```
use Adrii\CurlHelper;
```

### Manual

[](#manual)

```
require_once ROOT . 'CurlHelper.php';
```

Usage
-----

[](#usage)

```
$curl = new CurlHelper();
```

Methods
-------

[](#methods)

This section provides a quick start for users to understand how to apply the `CurlHelper` class in their projects for various HTTP requests, setting custom headers, and enabling debug mode for detailed request and response insights.

### GET Request

[](#get-request)

```
$curl->setUrl('http://example.com/api/data');
$curl->setGetParams(['key' => 'value']);
$curl->execute();
$response = $curl->response();
```

### POST Request

[](#post-request)

```
$curl->setUrl('http://example.com/api/data');
$curl->setPostParams(['key' => 'value']);
$curl->execute();
$response = $curl->response();
```

### PUT Request

[](#put-request)

```
$curl = new CurlHelper();
$curl->setUrl('https://example.com/api/data/1');
$curl->setPutParams(['key' => 'updatedValue']);
$curl->execute();
$response = $curl->response();
```

### DELETE Request

[](#delete-request)

```
$curl = new CurlHelper();
$curl->setUrl('https://example.com/api/data/1');
$curl->execute();
$response = $curl->response();
```

### Setting Custom Headers

[](#setting-custom-headers)

```
$curl->setUrl('http://example.com/api/data');
$curl->setPostParams(['key' => 'value']);
$curl->execute();
$response = $curl->response();
```

### Enabling Debug Mode

[](#enabling-debug-mode)

```
$curl->setDebug();
$curl->execute();
$debugInfo = $curl->debug();
```

### Handling Errors

[](#handling-errors)

The `execute` method throws an exception if the cURL request fails. Make sure to catch these exceptions and handle them accordingly.

```
try {
    $curl->execute();
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

Example
=======

[](#example)

These examples cover basic usage scenarios for CurlHelper. Modify parameters and URLs as needed to fit your specific use case.

```
$url    = '{url}';
$basic  = '{basic}';

$curl = new CurlHelper();

$curl->setUrl($url);

$curl->setPostParams([
    'param' => '{param}',
    'type' => '{type}'
]);

$curl->setHeaders([
    "Authorization" => "Basic {$basic}"
], false); // Disable parse (dafault Enabled:true)

$curl->setOptions([
    CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_2_0,
    CURLOPT_CONNECTTIMEOUT => 30,
]);

$curl->setMime("json");

$curl->setUtf8();

$curl->execute();

$response   = $curl->response();
$code       = $curl->http_code();

list($error, $msg) = $curl->parseCode();
```

Contributing
============

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
=======

[](#license)

CurlHelper is open-sourced software licensed under the [MIT](https://github.com/AdrianVillamayor/CurlHelper/blob/master/LICENSE)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

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

Recently: every ~85 days

Total

24

Last Release

754d ago

PHP version history (3 changes)v1.0PHP &gt;=7.0

1.7.3PHP &gt;=7.4

1.9.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

apicomposercurlcurl-wrappercurlhelperhelperhttphttp-clientlightweightphphttpapicurlhttp clientcurl wrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[aplus/http-client

Aplus Framework HTTP Client Library

2161.6M1](/packages/aplus-http-client)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[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)
