shaggyrec / php-http-client
Client for http requests from the php script
Installs: 1 265
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.2|^8.0
- ext-json: *
- symfony/http-client: ^5.1
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^8
README
Api client provide a way to make http request (to rest api, for example) with retrying ability. If response code >= 500, request will be retried several times. First retry in 1 second, second retry in 2 seconds, third retry in 4 seconds and so on, until 256 second limit was reach.
Installation
composer require shaggyrec/php-http-client
Usage
$response = Shaggyrec\PhpHttpClient\Client::getInstance('https://hostname.com')->post(
'/path/to/resource',
$requestJson,
[
'option' => '1',
'anotherOption' => '1',
],
[
'X-User-Id' => '666'
]);
You can use proxy or another options
Shaggyrec\PhpHttpClient\Client::getInstance(
'https://hostname.com',
['proxy' => 'http://username:password@ip:port/']
);
Tests
./tests/run.sh