stayforlong/finite-guzzlehttp

Guzzle HTTP client with finite timeouts

v0.1.0 2019-11-11 13:04 UTC

This package is auto-updated.

Last update: 2024-11-12 00:32:26 UTC


README

HTTP Client which grants finite timeouts for requests to avoid indefinite waits (Guzzle does).

Installation

Install the latest version through Composer:

$ composer require stayforlong/finite-guzzlehttp:0.1.0

Usage

Use dependency injection to autoload Guzzle, which is used under the hood:

<?php

use StayForLong\FiniteGuzzleHTTP\Client;

class MyClient {
    private $finiteClient;

    public function __construct(Client $client) {
        $this->finiteClient = $client;
    }

    public function finiteGet($unstableEndpoint) {
        $this->finiteClient->get($unstableEndpoint);
    }
}

// ...

try {
    $myClient->finiteGet(UNSTABLE_ENDPOINT);
} catch (ConnectException $e) {
    // do not let your requests wait forever
}