umonkey / php-http-client
Simple HTTP client
1.2.0
2020-07-01 10:00 UTC
Requires
- php: >=7.2
- umonkey/php-cache: dev-master
This package is auto-updated.
Last update: 2024-10-29 06:05:49 UTC
README
Very basic HTTP client for personal projects built on Slim framework.
Usage:
$settings = [
'httpClient' => [
'cache_size_limit' => 1048576, // 1 MB
'cache_ttl' => 86400, // 1 day
],
];
$http = new \Umonkey\Http($logger, $settings);
$res = $http->fetch($url);
if ($res->getStatus() !== 200) {
throw new \RuntimeException('error fetching resource');
}
var_dump($res);
In a Slim project, add this to config/dependencies.php
:
$container['http'] = function ($c) {
return $c['callableResolver']->getClassInstance('Umonkey\HttpClient');
};
Changes
2020/07/01:
- Added method HttpClient::urljoin().
- Added URL rewrite.