2017 © Pedro Pelรกez
 

library php-curl-class

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

image

php-curl-class/php-curl-class

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

  • PHP
  • 217 Dependents
  • 5 Suggesters
  • 568 Forks
  • 2 Open issues
  • 34 Versions
  • 11 % Grown

The README.md

PHP Curl Class: HTTP requests made easy

, (*1)

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs., (*2)

PHP Curl Class screencast, (*3)



โš™๏ธ Installation

To install PHP Curl Class, run the following command:, (*4)

composer require php-curl-class/php-curl-class

To install the latest commit version:, (*5)

composer require php-curl-class/php-curl-class @dev

Installation instructions to use the composer command can be found on https://github.com/composer/composer., (*6)

๐Ÿ“‹ Requirements

PHP Curl Class works with PHP 8.4, 8.3, 8.2, 8.1, 8.0, and 7.4., (*7)

๐Ÿš€ Quick Start and Examples

More examples are available under /examples., (*8)

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

use Curl\Curl;

$curl = new Curl();
$curl->get('https://www.example.com/');

if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage . "\n";
    $curl->diagnose();
} else {
    echo 'Response:' . "\n";
    var_dump($curl->response);
}
// https://www.example.com/search?q=keyword
$curl = new Curl();
$curl->get('https://www.example.com/search', [
    'q' => 'keyword',
]);
$curl = new Curl();
$curl->post('https://www.example.com/login/', [
    'username' => 'myusername',
    'password' => 'mypassword',
]);
$curl = new Curl();
$curl->setBasicAuthentication('username', 'password');
$curl->setUserAgent('MyUserAgent/0.0.1 (+https://www.example.com/bot.html)');
$curl->setReferrer('https://www.example.com/url?url=https%3A%2F%2Fwww.example.com%2F');
$curl->setHeader('X-Requested-With', 'XMLHttpRequest');
$curl->setCookie('key', 'value');
$curl->get('https://www.example.com/');

if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage . "\n";
} else {
    echo 'Response:' . "\n";
    var_dump($curl->response);
}

var_dump($curl->requestHeaders);
var_dump($curl->responseHeaders);
$curl = new Curl();
$curl->setFollowLocation();
$curl->get('https://shortn.example.com/bHbVsP');
$curl = new Curl();
$curl->put('https://api.example.com/user/', [
    'first_name' => 'Zach',
    'last_name' => 'Borboa',
]);
$curl = new Curl();
$curl->patch('https://api.example.com/profile/', [
    'image' => '@path/to/file.jpg',
]);
$curl = new Curl();
$curl->patch('https://api.example.com/profile/', [
    'image' => new CURLFile('path/to/file.jpg'),
]);
$curl = new Curl();
$curl->delete('https://api.example.com/user/', [
    'id' => '1234',
]);
// Enable all supported encoding types and download a file.
$curl = new Curl();
$curl->setOpt(CURLOPT_ENCODING , '');
$curl->download('https://www.example.com/file.bin', '/tmp/myfile.bin');
// Case-insensitive access to headers.
$curl = new Curl();
$curl->download('https://www.example.com/image.png', '/tmp/myimage.png');
echo $curl->responseHeaders['Content-Type'] . "\n"; // image/png
echo $curl->responseHeaders['CoNTeNT-TyPE'] . "\n"; // image/png
// Manual clean up.
$curl->close();
// 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);
require __DIR__ . '/vendor/autoload.php';

use Curl\MultiCurl;

// Requests in parallel with callback functions.
$multi_curl = new MultiCurl();

$multi_curl->success(function($instance) {
    echo 'call to "' . $instance->url . '" was successful.' . "\n";
    echo 'response:' . "\n";
    var_dump($instance->response);
});
$multi_curl->error(function($instance) {
    echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
    echo 'error code: ' . $instance->errorCode . "\n";
    echo 'error message: ' . $instance->errorMessage . "\n";
});
$multi_curl->complete(function($instance) {
    echo 'call completed' . "\n";
});

$multi_curl->addGet('https://www.google.com/search', [
    'q' => 'hello world',
]);
$multi_curl->addGet('https://duckduckgo.com/', [
    'q' => 'hello world',
]);
$multi_curl->addGet('https://www.bing.com/search', [
    'q' => 'hello world',
]);

$multi_curl->start(); // Blocks until all items in the queue have been processed.

More examples are available under /examples., (*9)

๐Ÿ“– Available Methods

Curl::__construct($base_url = null, $options = [])
Curl::__destruct()
Curl::__get($name)
Curl::afterSend($callback)
Curl::attemptRetry()
Curl::beforeSend($callback)
Curl::buildPostData($data)
Curl::call()
Curl::close()
Curl::complete($callback)
Curl::delete($url, $query_parameters = [], $data = [])
Curl::diagnose($return = false)
Curl::disableTimeout()
Curl::displayCurlOptionValue($option, $value = null)
Curl::download($url, $mixed_filename)
Curl::error($callback)
Curl::exec($ch = null)
Curl::execDone()
Curl::fastDownload($url, $filename, $connections = 4)
Curl::get($url, $data = [])
Curl::getAttempts()
Curl::getBeforeSendCallback()
Curl::getCompleteCallback()
Curl::getCookie($key)
Curl::getCurl()
Curl::getCurlErrorCode()
Curl::getCurlErrorMessage()
Curl::getDownloadCompleteCallback()
Curl::getDownloadFileName()
Curl::getErrorCallback()
Curl::getErrorCode()
Curl::getErrorMessage()
Curl::getFileHandle()
Curl::getHttpErrorMessage()
Curl::getHttpStatusCode()
Curl::getId()
Curl::getInfo($opt = null)
Curl::getJsonDecoder()
Curl::getOpt($option)
Curl::getOptions()
Curl::getRawResponse()
Curl::getRawResponseHeaders()
Curl::getRemainingRetries()
Curl::getRequestHeaders()
Curl::getResponse()
Curl::getResponseCookie($key)
Curl::getResponseCookies()
Curl::getResponseHeaders()
Curl::getRetries()
Curl::getRetryDecider()
Curl::getSuccessCallback()
Curl::getUrl()
Curl::getUserSetOptions()
Curl::getXmlDecoder()
Curl::head($url, $data = [])
Curl::isChildOfMultiCurl()
Curl::isCurlError()
Curl::isError()
Curl::isHttpError()
Curl::options($url, $data = [])
Curl::patch($url, $data = [])
Curl::post($url, $data = '', $follow_303_with_post = false)
Curl::progress($callback)
Curl::put($url, $data = [])
Curl::removeHeader($key)
Curl::reset()
Curl::search($url, $data = [])
Curl::setAutoReferer($auto_referer = true)
Curl::setAutoReferrer($auto_referrer = true)
Curl::setBasicAuthentication($username, $password = '')
Curl::setConnectTimeout($seconds)
Curl::setCookie($key, $value)
Curl::setCookieFile($cookie_file)
Curl::setCookieJar($cookie_jar)
Curl::setCookieString($string)
Curl::setCookies($cookies)
Curl::setDefaultDecoder($mixed = 'json')
Curl::setDefaultHeaderOut()
Curl::setDefaultJsonDecoder()
Curl::setDefaultTimeout()
Curl::setDefaultUserAgent()
Curl::setDefaultXmlDecoder()
Curl::setDigestAuthentication($username, $password = '')
Curl::setFile($file)
Curl::setFollowLocation($follow_location = true)
Curl::setForbidReuse($forbid_reuse = true)
Curl::setHeader($key, $value)
Curl::setHeaders($headers)
Curl::setInterface($interface)
Curl::setJsonDecoder($mixed)
Curl::setMaxFilesize($bytes)
Curl::setMaximumRedirects($maximum_redirects)
Curl::setOpt($option, $value)
Curl::setOpts($options)
Curl::setPort($port)
Curl::setProtocols($protocols)
Curl::setProxy($proxy, $port = null, $username = null, $password = null)
Curl::setProxyAuth($auth)
Curl::setProxyTunnel($tunnel = true)
Curl::setProxyType($type)
Curl::setRange($range)
Curl::setRedirectProtocols($redirect_protocols)
Curl::setReferer($referer)
Curl::setReferrer($referrer)
Curl::setRetry($mixed)
Curl::setStop($callback = null)
Curl::setTimeout($seconds)
Curl::setUrl($url, $mixed_data = '')
Curl::setUserAgent($user_agent)
Curl::setXmlDecoder($mixed)
Curl::stop()
Curl::success($callback)
Curl::unsetHeader($key)
Curl::unsetProxy()
Curl::verbose($on = true, $output = 'STDERR')
MultiCurl::__construct($base_url = null)
MultiCurl::__destruct()
MultiCurl::addCurl(Curl $curl)
MultiCurl::addDelete($url, $query_parameters = [], $data = [])
MultiCurl::addDownload($url, $mixed_filename)
MultiCurl::addGet($url, $data = [])
MultiCurl::addHead($url, $data = [])
MultiCurl::addOptions($url, $data = [])
MultiCurl::addPatch($url, $data = [])
MultiCurl::addPost($url, $data = '', $follow_303_with_post = false)
MultiCurl::addPut($url, $data = [])
MultiCurl::addSearch($url, $data = [])
MultiCurl::afterSend($callback)
MultiCurl::beforeSend($callback)
MultiCurl::close()
MultiCurl::complete($callback)
MultiCurl::disableTimeout()
MultiCurl::error($callback)
MultiCurl::getActiveCurls()
MultiCurl::getOpt($option)
MultiCurl::removeHeader($key)
MultiCurl::setAutoReferer($auto_referer = true)
MultiCurl::setAutoReferrer($auto_referrer = true)
MultiCurl::setBasicAuthentication($username, $password = '')
MultiCurl::setConcurrency($concurrency)
MultiCurl::setConnectTimeout($seconds)
MultiCurl::setCookie($key, $value)
MultiCurl::setCookieFile($cookie_file)
MultiCurl::setCookieJar($cookie_jar)
MultiCurl::setCookieString($string)
MultiCurl::setCookies($cookies)
MultiCurl::setDigestAuthentication($username, $password = '')
MultiCurl::setFile($file)
MultiCurl::setFollowLocation($follow_location = true)
MultiCurl::setForbidReuse($forbid_reuse = true)
MultiCurl::setHeader($key, $value)
MultiCurl::setHeaders($headers)
MultiCurl::setInterface($interface)
MultiCurl::setJsonDecoder($mixed)
MultiCurl::setMaximumRedirects($maximum_redirects)
MultiCurl::setOpt($option, $value)
MultiCurl::setOpts($options)
MultiCurl::setPort($port)
MultiCurl::setProxies($proxies)
MultiCurl::setProxy($proxy, $port = null, $username = null, $password = null)
MultiCurl::setProxyAuth($auth)
MultiCurl::setProxyTunnel($tunnel = true)
MultiCurl::setProxyType($type)
MultiCurl::setRange($range)
MultiCurl::setRateLimit($rate_limit)
MultiCurl::setReferer($referer)
MultiCurl::setReferrer($referrer)
MultiCurl::setRequestTimeAccuracy()
MultiCurl::setRetry($mixed)
MultiCurl::setTimeout($seconds)
MultiCurl::setUrl($url, $mixed_data = '')
MultiCurl::setUserAgent($user_agent)
MultiCurl::setXmlDecoder($mixed)
MultiCurl::start()
MultiCurl::stop()
MultiCurl::success($callback)
MultiCurl::unsetHeader($key)
MultiCurl::unsetProxy()
MultiCurl::verbose($on = true, $output = 'STDERR')

๐Ÿ”’ Security

See SECURITY for security considerations., (*10)

๐Ÿ› ๏ธ Troubleshooting

See TROUBLESHOOTING for help troubleshooting., (*11)

๐Ÿงช Testing

See TESTING for testing information., (*12)

๐Ÿค Contributing

  1. Check for open issues or open a new issue to start a discussion around a bug or feature.
  2. Fork the repository on GitHub to start making your changes.
  3. Write one or more tests for the new feature or that expose the bug.
  4. Make code changes to implement the feature or fix the bug.
  5. Send a pull request to get your changes merged and published.

The Versions

29/07 2018

dev-master

9999999-dev https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *
  • ext-mbstring *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

06/06 2018

8.1.0

8.1.0.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *
  • ext-mbstring *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

21/04 2018

8.0.3

8.0.3.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

09/04 2018

8.0.2

8.0.2.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

27/01 2018

8.0.1

8.0.1.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

02/11 2017

8.0.0

8.0.0.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

04/09 2017

7.4.0

7.4.0.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

28/06 2017

7.3.1

7.3.1.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

01/05 2017

7.3.0

7.3.0.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

27/01 2017

7.2.0

7.2.0.0 https://github.com/php-curl-class/php-curl-class

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

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

13/11 2016

7.1.0

7.1.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

27/09 2016

7.0.1

7.0.1.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

27/09 2016

7.0.0

7.0.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

03/09 2016

6.0.0

6.0.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

19/08 2016

5.1.0

5.1.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

07/08 2016

5.0.0

5.0.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

25/07 2016

4.13.0

4.13.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

16/07 2016

4.12.0

4.12.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

09/03 2016

4.11.0

4.11.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

31/01 2016

4.10.0

4.10.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

25/01 2016

4.9.0

4.9.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

31/10 2015

4.8.2

4.8.2.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

21/10 2015

4.8.1

4.8.1.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

15/10 2015

4.8.0

4.8.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

22/08 2015

4.6.9

4.6.9.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

13/08 2015

4.6.8

4.6.8.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

31/07 2015

4.6.7

4.6.7.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

29/07 2015

3.6.7

3.6.7.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

24/04 2015

3.5.5

3.5.5.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

api curl framework php json xml rest http restful client class web service requests http client

01/04 2015

3.4.4

3.4.4.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

curl php class

31/03 2015

3.4.3

3.4.3.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

by Zach Borboa

curl php class

18/12 2014

2.1.1

2.1.1.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

curl php class

07/07 2014

2.1.0

2.1.0.0 https://github.com/php-curl-class/php-curl-class

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download

Unlicense

The Requires

  • php >=5.3
  • ext-curl *

 

The Development Requires

curl php class

12/04 2014

2.0.0

2.0.0.0

PHP Curl Class is an object-oriented wrapper of the PHP cURL extension.

  Sources   Download