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

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

wykleph/curl
============

Simple synchronous and asynchronous cURL requests in php.

v0.11(10y ago)032MITPHP

Since Feb 3Pushed 10y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Curler
======

[](#curler)

A fluent API wrapper for libcurl in php. Setting options and headers is done using method chaining instead of setting options explicitly using the libcurl constants.

Debugging cURL commands in php using the Curler class is insanely simple as well. Just chain the `dryRun()` method onto the end of your method chain instead of the `go()` method and it will dump out all of the cURL request information without making the request.

See  for information on libcurl.

Note: This library is in its infancy.

Full documentation coming soon.

Getting Started
---------------

[](#getting-started)

##### Install using Composer

[](#install-using-composer)

Add `wykleph/curl` to your composer.json file or:

`composer require "wykleph/curl"`

You could also just copy the files in the `src` directory into your project if you aren't using composer, however I would recommend it.

##### Creat the Curler instance.

[](#creat-the-curler-instance)

```
$curler = new Curler('https://github.com/');
```

*Note that all of the following methods can be chained together unless noted otherwise*

##### Post information

[](#post-information)

```
$curler->post('fname', 'John')
    ->post('lname', 'Doe')
;
$curler->postArray(['fname'=>'John', 'lname'=>'Doe']);
```

##### Switch From POST to a GET request

[](#switch-from-post-to-a-get-request)

```
$curler->get();
```

##### Set Headers

[](#set-headers)

```
$curler->header('Connection', 'keep-alive')
    ->header('Host', 'github.com')
;
$curler->headerArray(['Connection'=>'keep-alive', 'Host'=>'github.com']);
```

##### Set User Agent or Referer

[](#set-user-agent-or-referer)

```
$ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0';

$curler->userAgent($ua)
    ->referer('http://github.com');
```

##### Save Cookies

[](#save-cookies)

```
$curler->cookieJar('SomeDirectory/testCookie');
```

##### Follow Browser Redirects

[](#follow-browser-redirects)

```
$curler->followRedirects();
```

##### Compressed Responses

[](#compressed-responses)

You can tell `Curler` you expect a compressed response from the request with `compressedResponse()`.

```
$curler->compressedResponse()
```

##### Upload a File

[](#upload-a-file)

Just give a form input name and a filepath.

```
$curler->upload('file', 'filepath');
```

##### Verbose Output

[](#verbose-output)

```
$curler->verbose();
```

##### Write Response to File

[](#write-response-to-file)

*multi-request support coming soon.*

```
$curler->writeResponse('someDirectory/Filename');
```

#### Preforming an Asynchronous Request, or Multi-Request

[](#preforming-an-asynchronous-request-or-multi-request)

You can send asynchronous requests as well! This can be accomplished through the use of AsyncCurler by adding URLs to the request(this retains any options that have been set in AsyncCurler up to this point), or by adding cURL handles to the request(adding handles as opposed to urls is somewhat untested.
It's in the works though).

```
$curler = new AsyncCurler();

$urls = [
    'https://github.com/',
    'http://pastebin.com/',
    'https://google.com/',
    'http://yahoo.com/'
];

$headers = [
    'Connection'        =>      'keep-alive',
    'Accept'            =>      'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language'   =>      'en-US,en;q=0.5',
    'Content-Type'      =>      'application/x-www-form-urlencoded'
];

$cookieJar = '/home/user/testCookie';

$curler->followRedirects()          // Exactly how it sounds.
    ->headerArray($headers)         // Add an array of headers.
    ->cookieJar($cookieJar)         // Set a location for cookies.
    ->returnText()                  // Don't display response.  Get a text string.
    ->suppressRender()              // This will suppress the html from rendering if it is echoed.
    ->addUrl($urls)                 // Add urls to the multi-request..
    ->addUrl('http://php.net/');    // or add them individually.

$html = $curler->go()->getResponse();

var_dump($html);
```

#### Debugging a request

[](#debugging-a-request)

Debug requests with ease by chaining the `dryRun()` method to the end of your method chain and dumping the result.

This will output something similar to this(consider using something like Symfony's `VarDumper` or Laravels dump and die - `dd()`):

```
 [
   "url" => "https://github.com/"
   "cookieJarFile" => "/home/parker/gitCookie"
   "headers" => [
     "Connection" => "keep-alive"
     "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
     "Accept-Language" => "en-US,en;q=0.5"
     "Host" => "github.com"
     "Content-Type" => "application/x-www-form-urlencoded"
   ]
   "postfields" => []
   "poststring" => ""
   "handles" => []
   "options" => [
     "CURLOPT_FOLLOWLOCATION" => true
     "CURLOPT_COOKIEFILE" => "/home/parker/gitCookie"
     "CURLOPT_COOKIEJAR" => "/home/parker/gitCookie"
     "CURLOPT_RETURNTRANSFER" => true
     "CURLOPT_HTTPHEADER" => [
       0 => "Connection: keep-alive"
       1 => "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
       2 => "Accept-Language: en-US,en;q=0.5"
       3 => "Host: github.com"
       4 => "Content-Type: application/x-www-form-urlencoded"
     ]
   ]
   "curl_getinfo" => [
     "url" => "https://github.com/"
     "content_type" => null
     "http_code" => 0
     "header_size" => 0
     "request_size" => 0
     "filetime" => 0
     "ssl_verify_result" => 0
     "redirect_count" => 0
     "total_time" => 0.0
     "namelookup_time" => 0.0
     "connect_time" => 0.0
     "pretransfer_time" => 0.0
     "size_upload" => 0.0
     "size_download" => 0.0
     "speed_download" => 0.0
     "speed_upload" => 0.0
     "download_content_length" => -1.0
     "upload_content_length" => -1.0
     "starttransfer_time" => 0.0
     "redirect_time" => 0.0
     "redirect_url" => ""
     "primary_ip" => ""
     "certinfo" => []
     "primary_port" => 0
     "local_ip" => ""
     "local_port" => 0
   ]
 ]
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Total

2

Last Release

3753d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1eb544e92c0645bf1868916c700865b5ca9fc3af9a8cca17829224cb09022aea?d=identicon)[Wykleph](/maintainers/Wykleph)

---

Tags

httprequestasynchronouswebautomationcurlcrawlerparallelbotspiderscraperrequestsmitMulti threadinternetweb request

### Embed Badge

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

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

###  Alternatives

[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[chuyskywalker/rolling-curl

Rolling-Curl: A non-blocking, non-dos multi-curl library for PHP

207446.6k6](/packages/chuyskywalker-rolling-curl)[khr/php-mcurl-client

wrap curl client (http client) for PHP 5.3; using php multi curl, parallel request and write asynchronous code

71219.8k6](/packages/khr-php-mcurl-client)[shuber/curl

PHP Wrapper for Curl

311.1M2](/packages/shuber-curl)[pear/http_request2

Provides an easy way to perform HTTP requests.

764.2M48](/packages/pear-http-request2)[duzun/hquery

An extremely fast web scraper that parses megabytes of HTML in a blink of an eye. No dependencies. PHP5+

363146.3k4](/packages/duzun-hquery)

PHPackages © 2026

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