PHP code example of umonkey / php-http-client
1. Go to this page and download the library: Download umonkey/php-http-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
umonkey / php-http-client example snippets
$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);
$container['http'] = function ($c) {
return $c['callableResolver']->getClassInstance('Umonkey\HttpClient');
};