PHPackages                             poor-plebs/guzzle-retry-after-middleware - 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. poor-plebs/guzzle-retry-after-middleware

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

poor-plebs/guzzle-retry-after-middleware
========================================

A guzzle middleware to keep track of the Retry-After HTTP header and fail consecutive requests until this time has passed.

3.1.0(1y ago)22.1k2MITPHPPHP ^8.1.0CI passing

Since Nov 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Poor-Plebs/guzzle-retry-after-middleware)[ Packagist](https://packagist.org/packages/poor-plebs/guzzle-retry-after-middleware)[ RSS](/packages/poor-plebs-guzzle-retry-after-middleware/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (9)Dependencies (10)Versions (12)Used By (2)

poor-plebs/guzzle-retry-after-middleware
========================================

[](#poor-plebsguzzle-retry-after-middleware)

[![CI](https://github.com/Poor-Plebs/guzzle-retry-after-middleware/actions/workflows/ci.yml/badge.svg)](https://github.com/Poor-Plebs/guzzle-retry-after-middleware/actions/workflows/ci.yml)

**[What is it for?](#what-is-it-for)** | **[What are the requirements?](#what-are-the-requirements)** | **[How to install it?](#how-to-install-it)** | **[How to use it?](#how-to-use-it)** | **[How to contribute?](#how-to-contribute)**

A guzzle middleware to keep track of the Retry-After HTTP header and fail consecutive requests until this time has passed.

What is it for?
---------------

[](#what-is-it-for)

Some HTTP servers may respond with a `Retry-After` [header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After), hinting the client when to resume doing further requests to the server. The reasons can differ in many ways, there is no strict case when to use that header. Most often it is used together with the response status code `429 Too Many Requests` doing rate limiting or with `503 Service Unavailable` when a dependency is offline or the server is in maintenance. In both cases the server hints the client when to retry the request to avoid preassure on the server that can not serve the request at that point in time. In some cases, if the client will not respect this back off request, the server may block or ban the client in some form.

To avoid that case, you can use this middleware that is specifically made for the [guzzle http](https://github.com/guzzle/guzzle) client. Following the documentation about middlewares, you can keep track of the retry after header's back off period so that requests during that period will fail with a dedicated exception before they are event sent out.

What are the requirements?
--------------------------

[](#what-are-the-requirements)

- PHP 8.0 or above

How to install it?
------------------

[](#how-to-install-it)

```
composer require poor-plebs/guzzle-retry-after-middleware
```

How to use it?
--------------

[](#how-to-use-it)

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use PoorPlebs\GuzzleRetryAfterMiddleware\RetryAfterException;

/* Any implementation of the PSR-16 (simple cache) interface. In case of using
 * this package with Laravel, it could look something like:
 */
$cache = Cache::store('array');

$handlerStack = HandlerStack::create();

// Where to put this middleware in the middleware stack depends on the usecase.
$handlerStack->unshift(
    new RetryAfterMiddleware($cache),
    'retry_after', // Name of the middlewere for debugging purposes.
);

$client = new Client([
    'base_uri' => 'https://sometest.com/',
    'handler' => $handlerStack,
    // Can be set/overwritten on per request basis as well.
    RetryAfterMiddleware::REQUEST_OPTION => 'cache_key_to_use',
]);

try {
    $client->postAsync('sendMessage')->wait();
} catch (RetryAfterException $exception) {
    // Do something when the library blocks requests.
}
```

How to contribute?
------------------

[](#how-to-contribute)

`poor-plebs/guzzle-retry-after-middleware` follows semantic versioning. Read more on [semver.org](https://semver.org).

Create issues to report problems or requests. Fork and create pull requests to propose solutions and ideas. Always add a CHANGELOG.md entry in the unreleased section.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 58.2% 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 ~98 days

Recently: every ~196 days

Total

9

Last Release

554d ago

Major Versions

1.1.1 → 2.0.02022-11-05

2.1.0 → 3.0.02022-12-18

PHP version history (2 changes)1.0.0PHP ^8.1.0

1.1.0PHP ^8.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7612582?v=4)[Petr Levtonov](/maintainers/TheLevti)[@TheLevti](https://github.com/TheLevti)

---

Top Contributors

[![TheLevti](https://avatars.githubusercontent.com/u/7612582?v=4)](https://github.com/TheLevti "TheLevti (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (23 commits)")

---

Tags

guzzleguzzle-middlewareguzzlehttphttphttp-headerphpphp8retry-after

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/poor-plebs-guzzle-retry-after-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/poor-plebs-guzzle-retry-after-middleware/health.svg)](https://phpackages.com/packages/poor-plebs-guzzle-retry-after-middleware)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

346132.9M112](/packages/google-cloud-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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