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

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

proclnas/curl-rox
=================

Just another curl wrapper for webCrawling purposes

3.0.0(7y ago)9194MITPHPPHP &gt;=7.3

Since Oct 7Pushed 7y ago2 watchersCompare

[ Source](https://github.com/proclnas/curl-rox)[ Packagist](https://packagist.org/packages/proclnas/curl-rox)[ Docs](https://github.com/proclnas/curl-rox)[ RSS](/packages/proclnas-curl-rox/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Curl Rox: Just another curl wrapper for webCrawling purposes
============================================================

[](#curl-rox-just-another-curl-wrapper-for-webcrawling-purposes)

[![Build Status](https://camo.githubusercontent.com/9bbdf73cf0d8020c5e4590fea20a8baeb72df4ca731103447393658f2d43b485/68747470733a2f2f6170692e7472617669732d63692e6f72672f70726f636c6e61732f6375726c2d726f782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/proclnas/curl-rox)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/proclnas/curl-rox/blob/master/LICENSE)[![Packagist](https://camo.githubusercontent.com/9b8cb8fdb221c54d659d888db33dd54491ebafa5287425b10dfe8990681585e2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d696e7374616c6c2d627269676874677265656e2e737667)](https://packagist.org/packages/proclnas/curl-rox)[![Code Coverage](https://camo.githubusercontent.com/7c2918aae815abf3e428f742fd200b4ab60db29179bce827e9f99fc6ea614d26/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f70726f636c6e61732f6375726c2d726f782e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/proclnas/curl-rox)

PHP Curl Rox Class is an object-oriented wrapper of the PHP cURL extension targeting webCrawling or similar tasks like api consuming.

---

- [Installation](#installation)
- [Requirements](#requirements)
- [How to use](#how-to-use)
- [Methods](#methods)
- [Todo](#todo)
- [License](#license)

---

### Installation

[](#installation)

To install PHP Curl Rox, Just:

```
# clone the repository
git clone https://github.com/proclnas/curl-rox.git
cd curl-rox

# install dependencies
composer install

# or require via composer
composer require proclnas/curl-rox
```

### Requirements

[](#requirements)

- PHP: 7.3
- ext-curl

### How to use

[](#how-to-use)

#### GET Request

[](#get-request)

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

use CurlRox\Curl;

try {

    $curl = new Curl;
    $curl->setUri('http://httpbin.org/get');
    $curl->getRequest();
    $r = $curl->getHttpResponse();

    echo $r;
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### POST Request

[](#post-request)

```
try {
    $curl = new Curl;
    $curl->setUri('http://httpbin.org/post');
    $curl->setPostPayload(['name' => 'Proclnas', 'Language' => 'PHP'])
    $curl->postRequest();
    $r = $curl->getHttpResponse();

    echo $r;
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### JSON parsing

[](#json-parsing)

Passing true to Curl::getHttpResponse automatically calls a json\_decode($http\_response, true) to the response

```
try {

    $curl = new Curl;
    $curl->setUri('http://httpbin.org/get');
    $curl->setHttpHeaders([
        'X-Requested-With' => 'XMLHttpRequest'
    ]);
    $curl->getRequest();
    $r = $curl->getHttpResponse(true);

    var_dump($r);
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### Parsing with dom (scraping all links in the page)

[](#parsing-with-dom-scraping-all-links-in-the-page)

CurlRox response extends [\\DiDom\\Document::loadHtml](https://github.com/Imangazaliev/DiDOM), allowing easy interaction with dom using the (\\DiDom\\Document $dom) parameter.

DiDom allows to interact with HTML in several ways, see here to more info: [Didom Repo](https://github.com/Imangazaliev/DiDOM)

```
try {
    $curl = new Curl;
    $curl->setUri('http://google.com');
    $curl->getRequest();

    $curl->setCallback(function($httpResponse, \DiDom\Document $dom, Curl $curlRox){
        $elements = $dom->find('a');

        foreach ($elements as $element)
            echo 'Link found: ', $element->attr('href'), PHP_EOL;
    });
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### Output

[](#output)

```
Link found: https://mail.google.com/mail/?tab=wm
Link found: https://www.google.com.br/imghp?hl=pt-BR&tab=wi&ei=jfkrV-q1CYS2wAS8oYH4CQ&ved=0EKouCBQoAQ
Link found: https://www.google.com.br/intl/pt-BR/options/
Link found: https://accounts.google.com/ServiceLogin?hl=pt-BR&passive=true&continue=https://www.google.com.br/%3Fgfe_rd%3Dcr%26ei%3DiPkrV-6uJo2dwQSsmKu4Dw%26gws_rd%3Dssl
Link found: javascript:void(0)
Link found: https://www.google.com/url?q=https://support.google.com/websearch/answer/463%3Futm_source%3Dgoogle.com%26utm_medium%3Dcallout%26utm_campaign%3DFFDHP&source=hpp&id=5082245&ct=7&usg=AFQjCNFBUGlUSE08cHgcuB_OXZHigRGNAw
Link found: https://www.google.com.br/webhp?hl=pt-BR
Link found: //support.google.com/websearch/answer/186645?hl=pt
Link found: //www.google.com.br/intl/pt-BR/policies/privacy/?fg=1
Link found: //www.google.com.br/intl/pt-BR/policies/terms/?fg=1
Link found: https://www.google.com.br/preferences?hl=pt-BR
Link found: https://www.google.com.br/preferences?hl=pt&fg=1
Link found: /advanced_search?hl=pt&fg=1

```

---

#### Check for 200' http code response (ok response)

[](#check-for-200-http-code-response-ok-response)

```
try {

    $curl = new Curl;
    $curl->setUri('http://fake-links.org/');
    $curl->getRequest();

    $curl->setCallback(function($http_response, \DiDom\Document $dom, Curl $curlRox){
        // Check http code
        if (!$curlRox->ok())
            exit (
                sprintf('Error reaching %s, http_code: %s' . PHP_EOL, $curlRox->getUri(), $curlRox->getHttpInfo('http_code'))
            );

        $elements = $dom->find('a');

        foreach ($elements as $element)
            echo 'Link found: ', $element->attr('href'), PHP_EOL;
    });
} catch (Exception $e) {
    echo $e->getMessage();
}
```

#### Save response to file (Debug reasons)

[](#save-response-to-file-debug-reasons)

```
try {

    $curl = new Curl;
    $curl->setUri('http://fake-links.org/');
    $curl->getRequest();
    $curl->debugTo('/tmp/review.html');

} catch (Exception $e) {
    echo $e->getMessage();
}
```

### Methods

[](#methods)

```
Curl::__construct($uri = null)
Curl::__destruct()
Curl::setUri($uri)
Curl::getUri()
Curl::setCookieFile($cookie_file);
Curl::getCookieFile()
Curl::setUserAgent($user_agent)
Curl::getUserAgent()
Curl::setRaw($raw = true)
Curl::getRaw()
Curl::setFollowLocation($follow_location)
Curl::getFollowLocation()
Curl::setTimeout($timeout)
Curl::getTimeout()
Curl::encoding($encoding)
Curl::getEncoding()
Curl::setHttpHeaders($http_headers)
Curl::getHttpHeaders()
Curl::setAutoReferer($bool)
Curl::getAutoReferer()
Curl::checkSsl($bool)
Curl::getCaCert()
Curl::getCheckSsl()
Curl::setPostPayload($post_payload)
Curl::getPostPayload()
Curl::getRequest()
Curl::postRequest()
Curl::getHttpInfo($http_info_key)
Curl::getHttpResponse($bool_json_decode)
Curl::ok()
Curl::getLastHttpCode()
Curl::setCallback($callable)
Curl::debugTo($file)
```

Todo
----

[](#todo)

- Add cases to PHPUnit test
- Better validation on setters
- Add CurlMulti support

Feel free to fork and pull request to help the project! ;)

### License

[](#license)

```
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 61.1% 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 ~309 days

Total

4

Last Release

2578d ago

Major Versions

1.0.0 → v2.x-dev2018-06-24

2.0.0 → 3.0.02019-04-23

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

v2.x-devPHP &gt;=5.6

3.0.0PHP &gt;=7.3

### Community

Maintainers

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

---

Top Contributors

[![proclnas](https://avatars.githubusercontent.com/u/3154242?v=4)](https://github.com/proclnas "proclnas (22 commits)")[![girorme](https://avatars.githubusercontent.com/u/54730507?v=4)](https://github.com/girorme "girorme (14 commits)")

---

Tags

crawlercurlcurlphpphphttpphpjsonapiclientrestcurlhttp clientweb serviceclassrestfulrequests

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-curl-class/php-curl-class

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.

3.3k9.5M353](/packages/php-curl-class-php-curl-class)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.0k](/packages/ismaeltoe-osms)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)

PHPackages © 2026

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