HTTP Client That Handles Retries and Logging

HTTP Client That Handles Retries and Logging

Gustavo Ocanto created an HTTP client on top of Guzzle that handles retries and logging. Typically you’d have some code like the following (and likely a try/catch too) if you need to retry an HTTP call:

use GuzzleHttp\Client;

$retry = 1;
$response = null;

do {
    $response = (new Client)->get('');
} while ($response === null && $retry <= 5);

With this client, you can achieve similar with the following code:

$response = (new Client)->retry(5)->get(''); 

If you need more granular control and want to tap into the retry routine, the package has an onRetry method:

$response = (new Client)->onRetry(function () {
    // Do stuff

You can learn more about this package, get full installation instructions, and view the source code on GitHub at gocanto/http-client.

Filed in: News / packages
Laravel News Partners

Laravel Jobs

Backend Software Engineer (PHP Developer)
Austin TX, Bonita Springs FL
Certified eSupport Corp
Laravel Developer
Glendale, CA (COVID Remote)
Jogg, Inc
Senior PHP Engineer
Remote, USA Only
Full-Stack Engineer (Mid to Senior)
Remote (EST, CST)
Senior Laravel Developer (AI Applications)
Remote from anywhere in the UK or from our London office
GreenShoot Labs


Join 31,000+ others and never miss out on new tips, tutorials, and more.