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)21.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 1mo 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 83% of packages

Maintenance40

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

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

507d 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

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)

PHPackages © 2026

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