From 6855273e6b6b5d1620d4a48cf92068f215913580 Mon Sep 17 00:00:00 2001 From: Rasmus Schultz Date: Thu, 4 Jul 2019 12:02:55 +0200 Subject: [PATCH] add docs --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b6901f5 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# `kodus/http-client` + +Minimalist [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client. + +[![PHP Version](https://img.shields.io/badge/php-7.1%2B-blue.svg)](https://packagist.org/packages/kodus/http-client) +[![Build Status](https://travis-ci.org/kodus/http-client.svg?branch=master)](https://travis-ci.org/kodus/http-client) +[![Code Coverage](https://scrutinizer-ci.com/g/kodus/http-client/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/kodus/http-client/?branch=master) + + * No dependencies beyond [PSR-17](https://www.php-fig.org/psr/psr-17/) HTTP Factory implementations + * Streaming response: suitable for fetching large responses. + * Accepts and decodes `gzip` encoded response content. + +Note that this client does not follow redirects: PSR-18 doesn't specify - but this is a client, not a browser, +and it's designed to be bootstrapped as a service instance: some dependents may need to know the status-code of +the actual response; automatically following redirects makes that impossible. + +## Usage + +Basic example using [`nyholm/psr7`](https://packagist.org/packages/nyholm/psr7): + +```php +use Kodus\Http\HttpClient; +use Nyholm\Psr7\Factory\Psr17Factory; + +// Bootstrap the client: + +$http = new Psr17Factory(); + +$client = new HttpClient($http, $http); + +// Perform a request: + +$response = $client->sendRequest( + $http->createRequest("GET", "https://postman-echo.com/get?foo=bar") +); +``` + +Please refer to [PSR-18 documentation](https://www.php-fig.org/psr/psr-18/) for details.