PHPackages                             leonardohipolito/laravel-http-client-rate-limiter-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. leonardohipolito/laravel-http-client-rate-limiter-middleware

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

leonardohipolito/laravel-http-client-rate-limiter-middleware
============================================================

This is my package laravel-http-client-rate-limiter-middleware

0.0.3(2y ago)052[2 PRs](https://github.com/leonardohipolito/laravel-http-client-rate-limiter-middleware/pulls)MITPHPPHP ^8.1

Since Sep 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/leonardohipolito/laravel-http-client-rate-limiter-middleware)[ Packagist](https://packagist.org/packages/leonardohipolito/laravel-http-client-rate-limiter-middleware)[ Docs](https://github.com/leonardohipolito/laravel-http-client-rate-limiter-middleware)[ RSS](/packages/leonardohipolito-laravel-http-client-rate-limiter-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (6)Used By (0)

A rate limiter to Laravel Http Client
=====================================

[](#a-rate-limiter-to-laravel-http-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/72c4e07365f7e86306db909ec38b18c2a4d59f0c09de08ce7f720773f8544804/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656f6e6172646f6869706f6c69746f2f6c61726176656c2d687474702d636c69656e742d726174652d6c696d697465722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leonardohipolito/laravel-http-client-rate-limiter-middleware)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6f2900ab8bbbaf57d585739ea166fe544969d35805ae73012264c7faafa2a024/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c656f6e6172646f6869706f6c69746f2f6c61726176656c2d687474702d636c69656e742d726174652d6c696d697465722d6d6964646c65776172652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/leonardohipolito/laravel-http-client-rate-limiter-middleware/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a4694dc234526656cf5d406559148ada0a92ebc38473ef70108e1640f3496610/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c656f6e6172646f6869706f6c69746f2f6c61726176656c2d687474702d636c69656e742d726174652d6c696d697465722d6d6964646c65776172652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/leonardohipolito/laravel-http-client-rate-limiter-middleware/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/97616d69c4f26ead8d5dd5172f9630653a403b8d3c50ac97dc6db02f8df937ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c656f6e6172646f6869706f6c69746f2f6c61726176656c2d687474702d636c69656e742d726174652d6c696d697465722d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/leonardohipolito/laravel-http-client-rate-limiter-middleware)

A rate limiter middleware for Laravel Http Client. Here's what you need to know:

- Specify a maximum amount of requests per minute or per second
- When the limit is reached, the process will `sleep` until the request can be made
- Implement your own driver to persist the rate limiter's request store. This is necessary if the rate limiter needs to work across separate processes, the package ships with an `InMemoryStore`.

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

[](#installation)

You can install the package via composer:

```
composer require leonardohipolito/laravel-http-client-rate-limiter-middleware
```

Usage
-----

[](#usage)

### Laravel 9

[](#laravel-9)

```
use GuzzleHttp\Middleware;
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\RateLimiterMiddleware;
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\CacheStore;
Http::macro(
    'jsonPlaceholder',
    fn () => Http::baseUrl('https://jsonplaceholder.typicode.com')
        ->withMiddleware(Middleware::mapRequest(RateLimiterMiddleware::perMinute(60, new CacheStore('jsonplaceholder-rate-limit'))))
        ->acceptJson()
        ->asJson()
);
```

### Laravel 10

[](#laravel-10)

```
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\RateLimiterMiddleware;
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\CacheStore;
Http::macro(
    'jsonPlaceholder',
    fn () => Http::baseUrl('https://jsonplaceholder.typicode.com')
        ->withRequestMiddleware(RateLimiterMiddleware::perMinute(60, new CacheStore('jsonplaceholder-rate-limit')
        ->acceptJson()
        ->asJson()
);
```

You can create a rate limiter to limit per second or per minute.

```
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\RateLimiterMiddleware;

RateLimiterMiddleware::perSecond(5);
RateLimiterMiddleware::perMinute(60);
```

Custom stores
-------------

[](#custom-stores)

By default, the rate limiter works in Cache. This means that if you have a second PHP process but you can create your own store.

```
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\RateLimiterMiddleware;
use MyApp\RateLimiterStore;
use \LeonardoHipolito\LaravelHttpClientRateLimiterMiddleware\RateLimit;

RateLimiterMiddleware::perSecond(3, new RateLimiterStore());
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Leonardo Hipolito](https://github.com/leonardohipolito)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~2 days

Total

3

Last Release

980d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06afd570b7de07ccf6c1658466c3c2367a362f98b5baff9c5179cee1182c2612?d=identicon)[leonardohipolito](/maintainers/leonardohipolito)

---

Top Contributors

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

---

Tags

laravelleonardohipolitolaravel-http-client-rate-limiter-middleware

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/leonardohipolito-laravel-http-client-rate-limiter-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/leonardohipolito-laravel-http-client-rate-limiter-middleware/health.svg)](https://phpackages.com/packages/leonardohipolito-laravel-http-client-rate-limiter-middleware)
```

###  Alternatives

[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[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)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[pdphilip/cf-request

Cloudflare Laravel Request

2725.6k1](/packages/pdphilip-cf-request)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

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