Retry extension for PSR-18 HTTP client.
Install this package and your favorite psr-18 implementation.
composer require webclient/ext-retry:^1.0
<?php
use Webclient\Extension\Retry\RetryClientDecorator;
use \Webclient\Extension\Retry\Timer\Timer;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
/**
* @var ClientInterface $client Your PSR-18 HTTP Client
* @var Timer $timer Timer implements
* @var int $maxAttempts Max attempts
*/
$http = new RetryClientDecorator($client, $timer, $maxAttempts);
/** @var RequestInterface $request */
$response = $http->sendRequest($request);