PHPackages                             mingalevme/retryable-psr-http-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. mingalevme/retryable-psr-http-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

mingalevme/retryable-psr-http-client
====================================

The package provides a familiar PSR HTTP Client interface with automatic retries and exponential backoff (and others strategies). It is a thin wrapper over the standard PSR HTTP Client and exposes same public API. This makes the decorator very easy to drop into existing programs.

2.1.0(8mo ago)6258↓100%1MITPHPPHP ^8.0CI passing

Since Dec 19Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/mingalevme/retryable-psr-http-client-php)[ Packagist](https://packagist.org/packages/mingalevme/retryable-psr-http-client)[ Docs](https://github.com/mingalevme/retryable-psr-http-client-php)[ RSS](/packages/mingalevme-retryable-psr-http-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

mingalevme/retryable-psr-http-client-php
========================================

[](#mingalevmeretryable-psr-http-client-php)

[![quality](https://github.com/mingalevme/retryable-psr-http-client-php/actions/workflows/quality.yml/badge.svg)](https://github.com/mingalevme/retryable-psr-http-client-php/actions)[![codecov](https://camo.githubusercontent.com/01ce9c414d7a4e455c5edffd7caaba48f0e735633d35de9259b73abe53afb0fd/68747470733a2f2f636f6465636f762e696f2f67682f6d696e67616c65766d652f726574727961626c652d7073722d687474702d636c69656e742d7068702f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4a656c667244664f6b4a)](https://codecov.io/gh/mingalevme/retryable-psr-http-client-php)[![version](https://camo.githubusercontent.com/569370f166810e8f095b1ae25b277730b74c1eb1c92ea686fc5e9bdd72d07aae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696e67616c65766d652f726574727961626c652d7073722d687474702d636c69656e74)](https://packagist.org/packages/mingalevme/retryable-psr-http-client)[![license](https://camo.githubusercontent.com/9b54505f382016ec8098bbf3c4e4e2083d7772aa138da2b655b4b5db35e41a05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d696e67616c65766d652f726574727961626c652d7073722d687474702d636c69656e74)](https://packagist.org/packages/mingalevme/retryable-psr-http-client)

Simple Retryable Psr Http Client Decorator with **Retry-After**-header support\* and 100% code coverage.

> ***NOTE:*** **Retry-After**-header handling is disabled by default because relying on untrusted headers it risky and dangerous, turn it on only if you clearly understand the consequences.

**Composer**

```
composer require mingalevme/retryable-psr-http-client
```

**Example 1 (Simple drop-in replacement)**

- Max **3** attempts.
- Triggers on **5xx**/**429** response status codes and/or `Psr\Http\Client\ClientExceptionInterface`.
- Exponential backoff: 2 power of attempt number (1, 2, 4, 8, ...).

```
use Mingalevme\RetryablePsrHttpClient\RetryablePsrHttpClient;
use Psr\Http\Client\ClientInterface;

$someDiContainer->decorate(ClientInterface::class, function (ClientInterface $client): RetryablePsrHttpClient {
    return new RetryablePsrHttpClient($client);
});
```

**Example 2 (Extended Usage)**

- Max **5** attempts.
- Respect **Retry-After**-header.
- Liner backoff with 1s (initial value) + 2s (slope).
- Triggers on 4xx, 5xx and `Psr\Http\Client\ClientExceptionInterface`.
- Log on any error (unacceptable response or `Psr\Http\Client\ClientExceptionInterface`-exception).

```
logger->error("Error while sending request {$request->getUri()}, attempt #$attemptNumber");
    }
}

final class MyAppHttpResponseAnalyzer implements ResponseAnalyzerInterface
{
    public function isAcceptable(ResponseInterface $response): bool
    {
        return $response->getStatusCode() >= 400;
    }
}

$someDiContainer->decorate(
    ClientInterface::class,
    function (
        ClientInterface $client,
        MyAppHttpClientErrLogEventListener $listener,
        MyAppHttpResponseAnalyzer $responseAnalyzer,
    ): RetryablePsrHttpClient {
        $config = Config::new()
            ->setRetryCount(5)
            ->setRespectRetryAfterHeader(true)
            ->setBackoffCalc(new LinearBackoffCalc(2, 1))
            ->setResponseAnalyzer($responseAnalyzer)
            ->addEventListener($listener);
        return new RetryablePsrHttpClient($client, $config);
    },
);
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance59

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~489 days

Total

3

Last Release

258d ago

Major Versions

1.0.0 → 2.0.02024-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/b7ec129880f05c65026a684ac899ac5c6a20334d1528f361265e2f526fbbec15?d=identicon)[mingalevme](/maintainers/mingalevme)

---

Top Contributors

[![mingalevme](https://avatars.githubusercontent.com/u/1725784?v=4)](https://github.com/mingalevme "mingalevme (23 commits)")

---

Tags

psrhttp client

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mingalevme-retryable-psr-http-client/health.svg)

```
[![Health](https://phpackages.com/badges/mingalevme-retryable-psr-http-client/health.svg)](https://phpackages.com/packages/mingalevme-retryable-psr-http-client)
```

###  Alternatives

[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)[kriswallsmith/buzz

Lightweight HTTP client

2.0k31.3M440](/packages/kriswallsmith-buzz)[art4/requests-psr18-adapter

Use WordPress/Requests as a PSR-18 HTTP client

153.3k](/packages/art4-requests-psr18-adapter)[simpod/clickhouse-client

PHP ClickHouse Client

19116.7k](/packages/simpod-clickhouse-client)[amphp/http-client-psr7

PSR-7 adapter for Amp's HTTP client.

1454.7k4](/packages/amphp-http-client-psr7)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
