PHPackages                             compwright/should-retry - 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. compwright/should-retry

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

compwright/should-retry
=======================

PSR interop HTTP retry middleware helper

v1.0.0(1y ago)14.2k↓20%2MITPHPPHP ^8.1 || ^8.2 || ^8.3 || ^8.4CI passing

Since Mar 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/compwright/should-retry)[ Packagist](https://packagist.org/packages/compwright/should-retry)[ Docs](https://github.com/compwright/should-retry)[ RSS](/packages/compwright-should-retry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (3)Used By (2)

compwright/should-retry
=======================

[](#compwrightshould-retry)

Installation
------------

[](#installation)

```
$ composer require compwright/should-retry

```

Usage with Guzzle HTTP library
------------------------------

[](#usage-with-guzzle-http-library)

The popular Guzzle HTTP library includes a retry middleware:

```
use Compwright\ShouldRetry\ShouldRetry;
use Compwright\ShouldRetry\RetryAfter;

$handler = GuzzleHttp\HandlerStack::create();

$handler->push(
    GuzzleHttp\Middleware::retry(
        new ShouldRetry(),
        new RetryAfter()
    ),
    'retry'
);

$client = new GuzzleHttp\Client([
    'handler' => $handler,
]);
```

Configuration
-------------

[](#configuration)

Both ShouldRetry and RetryAfter are configurable via setters:

```
$shouldRetry = (new ShouldRetry())
    ->setMaxRetries(5)
    ->setRetryOnStatusCodes(429)
    ->setLogger($logger); // attach PSR-3 debug logger

$retryAfter = (new RetryAfter())
    ->setRetryAfterHeader('x-rate-limit-reset')
    ->setFallbackStrategy($fallback);
```

Default configuration:

- Retry up to 3 times
- Retry on 429, 500, 502, 503, 504 error codes
- When retrying, wait `Retry-After` seconds
- If header is missing, use exponential backoff

License
-------

[](#license)

MIT License

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance45

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

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

Unknown

Total

1

Last Release

430d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/138688?v=4)[Jonathon Hill](/maintainers/compwright)[@compwright](https://github.com/compwright)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

psr-7Guzzlepsr-15

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/compwright-should-retry/health.svg)

```
[![Health](https://phpackages.com/badges/compwright-should-retry/health.svg)](https://phpackages.com/packages/compwright-should-retry)
```

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[mezzio/mezzio-swoole

Swoole support for Mezzio

92238.9k3](/packages/mezzio-mezzio-swoole)[sunrise/http-router

A powerful solution as the foundation of your project.

16249.8k10](/packages/sunrise-http-router)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[jasny/auth

Authentication, authorization and access control for Slim Framework and other PHP micro-frameworks

11816.4k1](/packages/jasny-auth)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)

PHPackages © 2026

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