sunrise/http-client-curl

Sunrise // HTTP cURL client for PHP 7.1+ (incl. PHP 8) based on PSR-18

v1.3.0 2021-02-01 17:44 UTC

This package is auto-updated.

Last update: 2021-04-06 15:18:15 UTC


README

Gitter Build Status Code Coverage Scrutinizer Code Quality Total Downloads Latest Stable Version License

Installation

composer require sunrise/http-client-curl

How to use?

Sunrise HTTP Factory

composer require sunrise/http-factory
use Sunrise\Http\Client\Curl\Client;
use Sunrise\Http\Factory\RequestFactory;
use Sunrise\Http\Factory\ResponseFactory;

$client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

// just use PSR-7 Response object...

Zend Diactoros

composer require zendframework/zend-diactoros
use Sunrise\Http\Client\Curl\Client;
use Zend\Diactoros\RequestFactory;
use Zend\Diactoros\ResponseFactory;

$client = new Client(new ResponseFactory());
$request = (new RequestFactory)->createRequest('GET', 'http://php.net/');
$response = $client->sendRequest($request);

// just use PSR-7 Response object...

cURL options

$client = new Client(new ResponseFactory(), [
    \CURLOPT_AUTOREFERER => true,
    \CURLOPT_FOLLOWLOCATION => true,
    \CURLOPT_MAXREDIRS => 10,
]);

Test run

composer test

Useful links