2017 © Pedro Peláez
 

library http-client

PSR-18 compatible HTTP client with middleware support

image

zelenin/http-client

PSR-18 compatible HTTP client with middleware support

  • Wednesday, March 21, 2018
  • by zelenin
  • Repository
  • 2 Watchers
  • 23 Stars
  • 367 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 12 Versions
  • 30 % Grown

The README.md

HTTP client Build Status Coverage Status

PSR-18 compatible low-level HTTP client with middleware support., (*1)

Installation

Composer

The preferred way to install this extension is through Composer., (*2)

Either run, (*3)

php composer.phar require zelenin/http-client "~4.0.0"

or add, (*4)

"zelenin/http-client": "~4.0.0"

to the require section of your composer.json, (*5)

Usage

use Zelenin\HttpClient\ClientFactory;
use Zend\Diactoros\Request;
use Zend\Diactoros\Uri;

$client = (new ClientFactory())->create();

$request = new Request(new Uri('https://example.com/'), 'GET');
$response = $client->sendRequest($request);

Full example with middleware stack

use Zelenin\HttpClient\Middleware\Cookie\CookieRequest;
use Zelenin\HttpClient\Middleware\Cookie\CookieResponse;
use Zelenin\HttpClient\Middleware\Cookie\FileStorage;
use Zelenin\HttpClient\Middleware\Deflate;
use Zelenin\HttpClient\Middleware\UserAgent;
use Zelenin\HttpClient\MiddlewareClient;
use Zelenin\HttpClient\RequestConfig;
use Zelenin\HttpClient\Transport\CurlTransport;
use Zend\Diactoros\Request;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\StreamFactory;
use Zend\Diactoros\Uri;

$streamFactory = new StreamFactory();
$responseFactory = new ResponseFactory();

$cookieStorage = new FileStorage('/tmp/http-client/cookies.storage');

$client = new MiddlewareClient([
    new CookieRequest($cookieStorage),
    new UserAgent(sprintf('HttpClient PHP/%s', PHP_VERSION)),
    new Deflate($streamFactory),
    new CookieResponse($cookieStorage),
    new CurlTransport($streamFactory, $responseFactory, new RequestConfig()),
], $responseFactory);

$request = new Request(new Uri('https://example.com/'), 'GET');
$response = $client->sendRequest($request);

Author

Aleksandr Zelenin, e-mail: aleksandr@zelenin.me, (*6)

The Versions

21/03 2018

dev-master

9999999-dev https://github.com/zelenin/http-client

PSR-18 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client psr-18

21/03 2018

dev-psr-15-middlewares

dev-psr-15-middlewares https://github.com/zelenin/http-client

PSR-18 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client psr-18

21/03 2018

3.0.0

3.0.0.0 https://github.com/zelenin/http-client

PSR-18 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client psr-18

20/03 2018

2.0.0

2.0.0.0 https://github.com/zelenin/http-client

PSR-18 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client psr-18

02/11 2017

1.0.3

1.0.3.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

31/10 2017

1.0.2

1.0.2.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

19/07 2017

1.0.1

1.0.1.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

08/06 2017

1.0.0

1.0.0.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

15/01 2017

0.1.0

0.1.0.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

13/01 2017

0.0.5

0.0.5.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

13/01 2017

0.0.3

0.0.3.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 http client

11/01 2017

0.0.1

0.0.1.0 https://github.com/zelenin/http-client

PSR-7 compatible HTTP client with middleware support

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http client