2017 © Pedro PelΓ‘ez
 

library http-curl-client

cURL client for PHP-HTTP

image

arhitector/http-curl-client

cURL client for PHP-HTTP

  • Friday, March 25, 2016
  • by Arhitector
  • Repository
  • 1 Watchers
  • 0 Stars
  • 54 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Curl client for PHP HTTP

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads, (*1)

The client for sending requests of PSR-7. The cURL client use the cURL PHP extension which must be activated in your php.ini., (*2)

Differences from https://github.com/php-http/curl-client

  • Support custom method, such as "MOVE", "COPY", "PROPFIND", "MKCOL" etc. (it is actual by operation with WebDav)
  • Fixed supports transmission of big bodies (upload and download).
  • Full support of native streaming filters, such as 'zlib.deflate' etc.
  • Fixed bug with queues in async request.
  • Doesn't lead to hangup of the server, in case of the inexact size of a flow.
  • More friendly api.
  • Inheritance support.
  • You can use options "CURLOPT_READFUNCTION" and "CURLOPT_WRITEFUNCTION".
  • Support of an native option "CURLOPT_FOLLOWLOCATION". (if you need support cookie with redirect - use "CURLOPT_COOKIEJAR" and "CURLOPT_COOKIEFILE")
  • Support send "PSR-7 Response".
  • More correct support of header "Expect"

Install

Via Composer, (*3)

$ composer require arhitector/http-curl-client:~1.3

Quickstart

For example with Zend/Diactoros:, (*4)

use Http\Message\MessageFactory\DiactorosMessageFactory;
use Http\Message\StreamFactory\DiactorosStreamFactory;

$client = new Mackey\Http\Client\Curl\Client(new DiactorosMessageFactory(), new DiactorosStreamFactory(), [
  // array, set default curl options, if you need
  CURLOPT_SSL_VERIFYPEER => false
]);

Send request, (*5)

$request = new Zend\Diactoros\Request('<url>', 'GET');

$response = $client->sendRequest($request, [
  // curl options for 1 request, if you need
  CURLOPT_FOLLOWLOCATION => true
]);

Send async request, (*6)

$request = new Zend\Diactoros\Request('<url>', 'GET');

$promise = $client->sendAsyncRequest($request);
$promise->then(
  function (ResponseInterface $response) {
    // The success callback

    return $response;
  },
  function (\Exception $exception) {
    // The failure callback

    throw $exception;
  }
);

// other request
// $promise = $client->sendAsyncRequest($request);

try {
    $response = $promise->wait();
} catch (\Exception $exception) {
    echo $exception->getMessage();
}

Send response, (*7)

// example just send file in output
$stream = new \Zend\Diactoros\Stream('file/to/send.txt');
$response = new \Zend\Diactoros\Response($stream, 200);

$client->sendResponse($response);

// or send for download
$response = $response->withHeader('Content-Description', 'File Transfer')
    ->withHeader('Content-Type', 'application/octet-stream')
    ->withHeader('Content-Disposition', 'attachment; filename=filename.txt')
    ->withHeader('Content-Transfer-Encoding', 'binary');

$client->sendResponse($response);

Documentation

Please see the official documentation., (*8)

Testing

bash $ composer test, (*9)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*10)

Security

If you discover any security related issues, please contact us at security@php-http.org., (*11)

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

25/03 2016
25/03 2016
16/03 2016
29/01 2016

v1.1.0

1.1.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http

28/01 2016

v1.0.0

1.0.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http

26/01 2016

v0.7.0

0.7.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http

14/12 2015
24/11 2015

v0.3.0

0.3.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http

17/11 2015

v0.2.0

0.2.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http

11/11 2015

v0.1.0

0.1.0.0 http://php-http.org

cURL client for PHP-HTTP

  Sources   Download

MIT

The Requires

 

The Development Requires

by ΠœΠΈΡ…Π°ΠΈΠ» ΠšΡ€Π°ΡΠΈΠ»ΡŒΠ½ΠΈΠΊΠΎΠ²

curl http