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

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

ledc/curl
=========

基于Curl的请求类库

v8.1.5(9mo ago)02135MITPHPPHP &gt;=8.1

Since Aug 7Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/ledccn/curl)[ Packagist](https://packagist.org/packages/ledc/curl)[ RSS](/packages/ledc-curl/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (20)Used By (5)

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 ledc/curl
```

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

[](#usage-examples)

A few example for using CURL with get:

```
use Ledc\Curl\Curl;

$curl = (new 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();
```

upload file metadata

```
use Ledc\Curl\Curl;

$curl = new Curl();
$json = '[{"length":7533293969,"path":["Brotherhood.of.the.Wolf.2001.BluRay.1080p.x265.10bit.2Audio.mkv"]},{"length":958431,"path":["cover.jpg"]},{"length":760,"path":["Brotherhood.of.the.Wolf.2001.BluRay.1080p.x265.10bit.2Audio.nfo"]}]';
$curl->addFile('file', '1.json', $json, 'application/json');
$curl->upload('http://www.example.com/upload');
$response = $curl->response;
printf($response);
```

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

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

An example using post

```
use Ledc\Curl\Curl;
$curl = new 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

```
use Ledc\Curl\Curl;
$curl = new 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:

```
use Ledc\Curl\Curl;
$curl = new 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

```
use Ledc\Curl\Curl;
$curl = new 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);
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance56

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

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

Recently: every ~18 days

Total

19

Last Release

291d ago

Major Versions

v1.1.5 → v2.0.02024-01-02

v2.0.2 → v8.0.02024-03-27

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M90](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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