PHPackages                             phpcurl/curlwrapper - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. phpcurl/curlwrapper

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phpcurl/curlwrapper
===================

The simplest OOP wrapper for curl, curl\_multi, curl\_share functions. Use CURL as a dependency, not hard-coded!

3.0.0(7y ago)11110.4k↓43.9%53MITPHPPHP &gt;=7.1.0CI failing

Since Feb 18Pushed 6y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (2)Versions (12)Used By (3)

CurlWrapper for PHP
===================

[](#curlwrapper-for-php)

[![Total Downloads](https://camo.githubusercontent.com/c71341a73a4ccd3e0e1e5c49a79cc68ba48e97390ee42f83e5b40a01c7bd6a12/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706375726c2f6375726c777261707065722e737667)](https://packagist.org/packages/phpcurl/curlwrapper)[![Latest Stable Version](https://camo.githubusercontent.com/bb3292e73dbc9a1dbf565e9d1bba28176982e900c0b33d8539479ee562d60d9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706375726c2f6375726c777261707065722e737667)](https://packagist.org/packages/phpcurl/curlwrapper)[![Travis Build](https://camo.githubusercontent.com/acf0887c7b258279fec678159f45bf5a1aa5da70759ddd742467e335d4174bda/68747470733a2f2f7472617669732d63692e6f72672f7068706375726c2f6375726c777261707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpcurl/curlwrapper)[![SensioLabs Insight](https://camo.githubusercontent.com/255d0ece559ebbaf7c5968cce43f0c3400149288186d95aeb818ce45f3338b89/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f66366464373136632d373732392d343666322d393033662d3132613533653432373834312e737667)](https://insight.sensiolabs.com/projects/f6dd716c-7729-46f2-903f-12a53e427841)

The simplest OOP-style wrapper for the standard php curl functions with no external dependencies. The main purpose is to make code that uses curl calls testable. We do it by injecting the Curl object as a dependency instead of calling curl functions directly.

Hard-coded dependencies. Not testable.

```
class MyApiClient {
    ...
    function call($url)
    {
        $ch = curl_init($url);
        curl_set_opt($ch, /*...*/)
        return curl_exec($ch);
    }
}
```

Testable code. Curl object is injected, so can be easily mocked in PHPUnit.

```
class MyApiClient {
    private $curl;
    function __construct(\PHPCurl\CurlWrapper\CurlInterface $curl)
    {
        $this->curl = $curl;
    }
    //...
    function call($url)
    {
        $this->curl->init($url);
        $this->curl->setOpt(/*...*/)
        return $this->curl->exec();
    }
}
```

Install
-------

[](#install)

Via [composer](https://getcomposer.org): `$ composer require "phpcurl/curlwrapper"`

Basic usage examples. Classic vs OOP style
------------------------------------------

[](#basic-usage-examples-classic-vs-oop-style)

### Curl

[](#curl)

ClassicOOP`$h = curl_init($url)``$curl = new Curl(); $curl->init($url)``curl_close($h)``unset($curl)``$e = curl_errno($h)``$e = $curl->errno()``$e = curl_error($h)``$e = $curl->error()``$i = curl_getinfo($h, $opt)``$i = $curl->getInfo($opt)``curl_setopt($h, $opt, $val)``$curl->setOpt($opt, $val)``curl_setopt_array($h, $array)``$curl->setOptArray($array)``curl_version($age)``$curl->version($age)``curl_strerror($errornum)``$curl->strerror($errornum)``$h2 = curl_copy_handle($h)``$curl2 = clone($curl)``$result = curl_exec($h)``$result = $curl->exec()``$res = curl_pause($h, $mask)``$res = $curl->pause($mask)``$res = curl_escape($h, $str)``$res = $curl->escape($str)``$res = curl_unescape($h, $str)``$res = $curl->unescape($str)`### CurlMulti

[](#curlmulti)

ClassicOOP`curl_multi_init()``$cm = new CurlMulti(); $cm->init()``curl_multi_close($h)``unset($cm)``$i = curl_multi_add_handle($mh, $ch)``$i = $cm->add($curl)``$i = curl_multi_remove_handle($mh, $ch)``$i = $cm->remove($curl)``$i = curl_multi_exec($mh, $running)``$i = $cm->exec($running)``$s = curl_multi_getcontent($ch)``$s = $cm->getContent($curl)``$a = curl_multi_info_read($mh, $msgs)``$a = $cm->infoRead($msgs)``$i = curl_multi_select($mh, $timeout)``$i = $cm->select($timeout)``$r = curl_multi_setopt($h, $opt, $val)``$r = $cm->setOpt($opt, $val)`### CurlShare

[](#curlshare)

ClassicOOP`curl_share_init()``$cs = new CurlShare(); $cs->init()``curl_share_close($h)``unset($cs)``$r = curl_multi_setopt($h, $opt, $val)``$r = $cs->setOpt($opt, $val)`

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% 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 ~172 days

Recently: every ~162 days

Total

11

Last Release

2755d ago

Major Versions

0.1.2 → 1.0.02016-02-03

1.0.0 → 2.0.02017-01-21

v2.x-dev → 3.0.02018-11-02

PHP version history (3 changes)0.0.1PHP &gt;=5.3.0

2.0.0PHP &gt;=5.5.0

3.0.0PHP &gt;=7.1.0

### Community

Maintainers

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

---

Top Contributors

[![f3ath](https://avatars.githubusercontent.com/u/831399?v=4)](https://github.com/f3ath "f3ath (63 commits)")[![slax0rr](https://avatars.githubusercontent.com/u/3025605?v=4)](https://github.com/slax0rr "slax0rr (1 commits)")

---

Tags

curlcurl-multicurlwrapperdependency-injectioninjectableooptestingphpunitcurldependencyinjectionmockwrapperOOPtestablecurl\_multicurl\_sharePhpcurl

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/phpcurl-curlwrapper/health.svg)

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

###  Alternatives

[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)[donatj/mock-webserver

Simple mock web server for unit testing

1382.5M80](/packages/donatj-mock-webserver)[blastcloud/guzzler

Supercharge your app or SDK with a testing library specifically for Guzzle.

272419.3k35](/packages/blastcloud-guzzler)[janmarek/mockista

Mockista is library for mocking, which I've written, because I find mocking in PHPUnit awful.

29221.0k28](/packages/janmarek-mockista)[tcz/phpunit-mockfunction

PHPUnit extension that uses runkit to mock PHP functions (both user-defined and system)

4950.3k2](/packages/tcz-phpunit-mockfunction)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)

PHPackages © 2026

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