Minimalist PSR-18 HTTP Client
Minimalist PSR-18 HTTP Client.
- No dependencies beyond PSR-17 HTTP Factory implementations
- Streaming response: suitable for fetching large responses.
- Accepts and decodes
gzipencoded 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.
Basic example using
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 for details.