2017 © Pedro Peláez
 

library php-curl

A quick start PHP cURL library

image

jabranr/php-curl

A quick start PHP cURL library

  • Saturday, January 27, 2018
  • by jabranr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

PHP cURL Build Status Latest Stable Version Total Downloads

A simple PHP client for cURL operations., (*1)

Migrating from v1? Beware that v2 has breaking changes! Some of the API methods names have changed., (*2)

Simply import the library into your project. The best way to do so is to use Composer as following. Otherwise it can simply be downloaded from GitHub and added to the project., (*3)

$ composer require jabranr/php-curl

Start using it straight away. (Following example assumes that it was installed via Composer), (*4)

<?php

require 'path/to/vendor/autoload.php';

use Jabran\HttpUtil\HttpCurlRequest;
use Jabran\HttpUtil\Exception\HttpCurlException;

# Start new cURL request
$curl = new HttpCurlRequest('http://jabran.me');

Setting cURL options, (*5)

<?php

# Set options - method 1
$curl->setOption(CURLOPT_RETURNTRANSFER, true);
$curl->setOption(CURLOPT_FOLLOWLOCATION, true);

# Set options - method 2
$curl->setOptions(array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true
));

# Execute request, get response and close connection
try {
    $response = $curl->execute();
} catch(HttpCurlException $e) {
    $curl->getErrorCode(); // -> cURL error number
    $curl->getErrorMessage(); // -> cURL error message

    # OR

    $e->getMessage(); // -> cURL error: [ErrorCode] ErrorMessage
}

# OR get more info and close connection manually
try {
    $response = $curl->execute(false);
} catch(HttpCurlException $e) { }

# Get response later
$response = $curl->getResponse();

# 
$info = $curl->getInfo();

# Close request
$curl->close();

API

The cURL class exposes following API:, (*6)

getInfo

Get cURL request info. $option needs to be a valid cURL constant. If none given then it will return an associative array., (*7)

$curl->execute(false);
$curl->getInfo($option = null);
$curl->close();

getError

Get cURL request error message., (*8)

$curl->getError();

getErrorCode

Get cURL request error code., (*9)

$curl->getErrorCode();

getErrorMessage

Get cURL request error message., (*10)

$curl->getErrorMessage();

getHttpCode

Get cURL request HTTP status code., (*11)

$curl->getHttpCode();

getTotalTime

Get total time taken for a cURL request., (*12)

$curl->getTotalTime();

getResponse

Get response for a cURL request., (*13)

$curl->getResponse();

License

Feel free to use and send improvements via pull requests. Licensed under the MIT License., (*14)

© Jabran Rafique – 2016 – 2017, (*15)

The Versions

27/01 2018

dev-develop

dev-develop https://github.com/jabranr/php-curl

A quick start PHP cURL library

  Sources   Download

MIT MIT License

The Requires

  • php >=5.3.0

 

The Development Requires

curl php

27/01 2018

2.0.0

2.0.0.0 https://github.com/jabranr/php-curl

A quick start PHP cURL library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl php

26/01 2018

v1.x-dev

1.9999999.9999999.9999999-dev https://github.com/jabranr/php-curl

A quick start PHP cURL library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

curl php

17/05 2017

dev-issue-3-add-close-to-execute

dev-issue-3-add-close-to-execute https://github.com/jabranr/php-curl

Tiny PHP helper library to make cURL requests

  Sources   Download

MIT License

The Requires

  • php >=5.3.0

 

The Development Requires

curl php library

09/02 2017

dev-master

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

A quick start PHP cURL library

  Sources   Download

MIT License

The Requires

  • php >=5.3.0

 

The Development Requires

curl php

09/02 2017

1.0.1

1.0.1.0 https://github.com/jabranr/php-curl

A quick start PHP cURL library

  Sources   Download

MIT License

The Requires

  • php >=5.3.0

 

The Development Requires

curl php

10/10 2016

1.0.0

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

A quick start PHP cURL library

  Sources   Download

MIT License

The Requires

  • php >=5.3.0

 

The Development Requires

curl php