Skip to content

umonkey/php-http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple HTTP client

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.

About

Simple HTTP client

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages