shaggyrec/php-http-client

There is no license information available for the latest version (v1.2.0) of this package.

Client for http requests from the php script

v1.2.0 2022-05-04 04:55 UTC

This package is auto-updated.

Last update: 2024-04-17 10:57:02 UTC


README

Build Status

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