Diciotto is a no-nonsense PSR-18 compliant HTTP client library for PHP 7.
- Documentation should be unnecessary
- Provide sensible defaults
- Explicit is better than implicit
- Prefer a good Developer eXperience over performance
- No surprises
composer require fain182/diciotto
$httpClient = new HttpClient();
$response = $httpClient->sendRequest( new Request('http://www.google.com') );
$httpClient = new HttpClient();
$request = new JsonRequest('https://httpbin.org/put', 'POST', ['name' => 'value']);
$response = $httpClient->sendRequest($request);
The default timeout is 15 seconds.
$httpClient = (new HttpClient())->withTimeout(30);
$response = $httpClient->sendRequest( new Request('http://www.google.com') );
$httpClient = (new HttpClient())->withCheckSslCertificates(false);
$response = $httpClient->sendRequest( new Request('http://www.google.com') );
$httpClient = new HttpClient();
$request = (new Request('http://www.google.com'))->withAddedCookie('name', 'value');
$response = $httpClient->sendRequest( $request );
Diciotto raise exception if the request is invalid (RequestException
), or if there are network problems (NetworkException
).
Response with status code 4xx or 5xx are treated the same way as the others, so no exception or error is raised.
- Diciotto works with PHP 7.1 or above.
Diciotto is licensed under the MIT License - see the LICENSE
file for details
Diciotto is built on top of nyholm/psr7 that provides PSR-7 and PSR-17 implementation.