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

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

antihate/curl
=============

cURL class for PHP

02PHP

Since Dec 8Pushed 1y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Curl Class
==============

[](#php-curl-class)

This library provides an object-oriented and dependency free wrapper of the PHP cURL extension.

[![Maintainability](https://camo.githubusercontent.com/9a0f4e313286f2c8981dbc394475ed4c860b236516e09d7eac1cf8e1afc53a37/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36633334626233316633656236646633366337642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/php-mod/curl/maintainability)[![Test Coverage](https://camo.githubusercontent.com/523713c4154e36469a4245f91df3028c013ebbc3beff55ea55e76ebadea5d0bf/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f36633334626233316633656236646633366337642f746573745f636f766572616765)](https://codeclimate.com/github/php-mod/curl/test_coverage)[![Total Downloads](https://camo.githubusercontent.com/934bcd0ca16b72e2f6a7dbc22fa5dcf939167d0b5250b22996278e4eeaf8a9c2/68747470733a2f2f706f7365722e707567782e6f72672f6375726c2f6375726c2f646f776e6c6f616473)](//packagist.org/packages/curl/curl)[![Tests](https://github.com/php-mod/curl/actions/workflows/tests.yml/badge.svg)](https://github.com/php-mod/curl/actions/workflows/tests.yml)

If you have questions or problems with installation or usage [create an Issue](https://github.com/php-mod/curl/issues).

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

[](#installation)

In order to install this library via composer run the following command in the console:

```
composer require curl/curl
```

Usage examples
--------------

[](#usage-examples)

A few example for using CURL with get:

```
$curl = (new Curl\Curl())->get('http://www.example.com/');
if ($curl->isSuccess()) {
    // do something with response
    var_dump($curl->response);
}
// ensure to close the curl connection
$curl->close();
```

Or with params, values will be encoded with `PHP_QUERY_RFC1738`:

```
$curl = (new Curl\Curl())->get('http://www.example.com/search', [
    'q' => 'keyword',
]);
```

An example using post

```
$curl = new Curl\Curl();
$curl->post('http://www.example.com/login/', [
    'username' => 'myusername',
    'password' => 'mypassword',
]);
```

An exampling using basic authentication, remove default user agent and working with error handling

```
$curl = new Curl\Curl();
$curl->setBasicAuthentication('username', 'password');
$curl->setUserAgent('');
$curl->setHeader('X-Requested-With', 'XMLHttpRequest');
$curl->setCookie('key', 'value');
$curl->get('http://www.example.com/');

if ($curl->error) {
    echo $curl->error_code;
} else {
    echo $curl->response;
}

var_dump($curl->request_headers);
var_dump($curl->response_headers);
```

SSL verification setup:

```
$curl = new Curl\Curl();
$curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
$curl->get('https://encrypted.example.com/');
```

Example access to curl object:

```
curl_set_opt($curl->curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1');
curl_close($curl->curl);
```

Example of downloading a file or any other content

```
$curl = new Curl\Curl();
// open the file where the request response should be written
$file_handle = fopen($target_file, 'w+');
// pass it to the curl resource
$curl->setOpt(CURLOPT_FILE, $file_handle);
// do any type of request
$curl->get('https://github.com');
// disable writing to file
$curl->setOpt(CURLOPT_FILE, null);
// close the file for writing
fclose($file_handle);
```

Testing
-------

[](#testing)

In order to test the library:

1. Create a fork
2. Clone the fork to your machine
3. Install the depencies `composer install`
4. Build and start the docker image (in `tests/server`) `docker build . -t curlserver` start `docker run -p 1234:80 curlserver`
5. Run the unit tests `./vendor/bin/phpunit tests`

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/29ff66b763d1cfa13c27fd8a24dc1903f279d40b6fc4805446d7160df6d162cc?d=identicon)[AntiHate](/maintainers/AntiHate)

---

Top Contributors

[![nadar](https://avatars.githubusercontent.com/u/3417221?v=4)](https://github.com/nadar "nadar (83 commits)")[![amouhzi](https://avatars.githubusercontent.com/u/4458806?v=4)](https://github.com/amouhzi "amouhzi (80 commits)")[![AntiHate](https://avatars.githubusercontent.com/u/2887867?v=4)](https://github.com/AntiHate "AntiHate (9 commits)")[![zurborg](https://avatars.githubusercontent.com/u/1327863?v=4)](https://github.com/zurborg "zurborg (6 commits)")[![MikeLund](https://avatars.githubusercontent.com/u/17044744?v=4)](https://github.com/MikeLund "MikeLund (3 commits)")[![mrteye](https://avatars.githubusercontent.com/u/1945243?v=4)](https://github.com/mrteye "mrteye (2 commits)")[![KarelWintersky](https://avatars.githubusercontent.com/u/2164874?v=4)](https://github.com/KarelWintersky "KarelWintersky (2 commits)")[![MartijnBraam](https://avatars.githubusercontent.com/u/6928199?v=4)](https://github.com/MartijnBraam "MartijnBraam (2 commits)")[![stevepatter](https://avatars.githubusercontent.com/u/1690712?v=4)](https://github.com/stevepatter "stevepatter (2 commits)")[![user52](https://avatars.githubusercontent.com/u/3287452?v=4)](https://github.com/user52 "user52 (2 commits)")[![JanPetterMG](https://avatars.githubusercontent.com/u/11933090?v=4)](https://github.com/JanPetterMG "JanPetterMG (2 commits)")[![icemanpro](https://avatars.githubusercontent.com/u/1924688?v=4)](https://github.com/icemanpro "icemanpro (2 commits)")[![mean-cj](https://avatars.githubusercontent.com/u/1191385?v=4)](https://github.com/mean-cj "mean-cj (1 commits)")[![charlycoste](https://avatars.githubusercontent.com/u/352634?v=4)](https://github.com/charlycoste "charlycoste (1 commits)")[![paragonie-scott](https://avatars.githubusercontent.com/u/11591518?v=4)](https://github.com/paragonie-scott "paragonie-scott (1 commits)")[![zachborboa](https://avatars.githubusercontent.com/u/1083146?v=4)](https://github.com/zachborboa "zachborboa (1 commits)")[![daniel-zahariev](https://avatars.githubusercontent.com/u/263063?v=4)](https://github.com/daniel-zahariev "daniel-zahariev (1 commits)")[![andreustimm](https://avatars.githubusercontent.com/u/811102?v=4)](https://github.com/andreustimm "andreustimm (1 commits)")[![enrique-ibarra](https://avatars.githubusercontent.com/u/2584986?v=4)](https://github.com/enrique-ibarra "enrique-ibarra (1 commits)")[![evilangelmd](https://avatars.githubusercontent.com/u/6436504?v=4)](https://github.com/evilangelmd "evilangelmd (1 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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