php-extended/php-http-client-native

A psr-18 compliant client with the native stream engine.


README

A psr-18 compliant client with the native stream engine.

coverage build status

Installation

The installation of this library is made via composer. Download composer.phar from their website. Then add to your composer.json :

	"require": {
		...
		"php-extended/php-http-client-native": "^3",
		...
	}

Then run php composer.phar update to install this library. The autoloading of all classes of this library is made through composer's autoloader.

Basic Usage

This library uses the internal file_get_contents with the http resource context to perform http requests. You may use it the following way :


use PhpExtended\HttpClient\NativeClient;
use PhpExtended\HttpClient\NativeOptionsFactory;

/** @var $request Psr\Http\Message\Request */ // psr-7
/** @var $responseFactory \Psr\Http\Client\ResponseFactoryInterface */ // psr-18
/** @var $streamFactory \Psr\Http\Client\StreamFactoryInterface */ // psr-18

$client = new NativeClient($responseFactory, $streamFactory, new NativeOptionsFactory());
$response = $client->sendRequest($request);

// $response is an instance of Psr\Http\Message\Response

To enforce https, you should use the \PhpExtended\Certificate\CertificateProviderInterface argument of the client.

License

MIT (See license file).