2017 © Pedro Peláez
 

library curl

cURL class for PHP

image

php-mod/curl

cURL class for PHP

  • Wednesday, July 25, 2018
  • by amouhzi
  • Repository
  • 12 Watchers
  • 202 Stars
  • 1,020 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 80 Forks
  • 9 Open issues
  • 23 Versions
  • 4 % Grown

The README.md

PHP Curl Class

This library provides an object-oriented and dependency free wrapper of the PHP cURL extension., (*1)

Maintainability Test Coverage Total Downloads Tests, (*2)

If you have questions or problems with installation or usage create an Issue., (*3)

Installation

In order to install this library via composer run the following command in the console:, (*4)

composer require curl/curl

Usage examples

A few example for using CURL with get:, (*5)

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

Or with params, values will be encoded with PHP_QUERY_RFC1738:, (*6)

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

An example using post, (*7)

$curl = new Curl\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, (*8)

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

Example access to curl object:, (*9)

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, (*10)

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

Testing

In order to test the library:, (*11)

  1. Create a fork
  2. Clone the fork to your machine
  3. Install the depencies composer install
  4. Build and start the docker image (in tests/server) docker build . -t curlserver start docker run -p 1234:80 curlserver
  5. Run the unit tests ./vendor/bin/phpunit tests

The Versions

25/07 2018

dev-master

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

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

23/05 2018

1.9.1

1.9.1.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

02/05 2018

1.9.0

1.9.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

12/08 2017

1.8.0

1.8.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

09/08 2017

1.7.1

1.7.1.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

28/07 2017

1.7.0

1.7.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

03/04 2017

1.6.1

1.6.1.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

13/01 2017

1.6.0

1.6.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

20/10 2016

1.5.0

1.5.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

04/06 2016

1.4.0

1.4.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

16/12 2015

1.3.0

1.3.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

09/08 2015

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

curl

09/04 2015

1.2.1

1.2.1.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

08/03 2015

2.0.0-alpha1

2.0.0.0-alpha1 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4.0
  • ext-curl *

 

The Development Requires

curl

13/02 2015

dev-version-1

dev-version-1 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

11/12 2014

1.2.0

1.2.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

The Development Requires

curl dot

14/08 2014

1.1.5

1.1.5.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

22/06 2014

1.1.4

1.1.4.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

19/05 2014

1.1.3

1.1.3.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

09/04 2014

1.1.2

1.1.2.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

26/03 2014

1.1.1

1.1.1.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

04/11 2013

v1.1.0

1.1.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot

03/11 2013

1.0

1.0.0.0 https://github.com/php-mod/curl

cURL class for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl dot