PHPackages                             beholdr/laravel-backoff-limiter - 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. beholdr/laravel-backoff-limiter

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

beholdr/laravel-backoff-limiter
===============================

Rate limiter with exponential backoff for Laravel.

v0.1.3(4mo ago)26.0kMITPHPPHP ^8.1CI failing

Since Dec 21Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/beholdr/laravel-backoff-limiter)[ Packagist](https://packagist.org/packages/beholdr/laravel-backoff-limiter)[ Docs](https://github.com/beholdr/laravel-backoff-limiter)[ RSS](/packages/beholdr-laravel-backoff-limiter/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (24)Versions (5)Used By (0)

Backoff Limiter
===============

[](#backoff-limiter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8af0c0f30da8491fe82c16fc11af109e0da6076f355e33f1f12c15e52b69ddd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265686f6c64722f6c61726176656c2d6261636b6f66662d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beholdr/laravel-backoff-limiter)

Rate limiter with exponential backoff for Laravel.

Imagine that you want to verify your customer's phone number by sending an SMS code. But sending SMS is expensive and you don't want to allow too many requests. Laravel has [RateLimiter](https://laravel.com/docs/rate-limiting) class, but it is very simple. Let's say you accept 1 attempt per minute, but this allows some unfriendly person to send 1 SMS every minute without any penalties.

Using `BackoffLimiter` class you can increase backoff exponentially with every attempt. For example, first retry will be available in 1 minute, second in 4 minutes, third in 9 minutes etc. Backoff time is determined by the formula:

```
backoff_time = decay_time * attempts ^ exponent

```

Support
-------

[](#support)

Do you like **Backoff Limiter**? Please support me via [Boosty](https://boosty.to/beholdr).

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

[](#installation)

You can install the package via composer:

```
composer require beholdr/laravel-backoff-limiter
```

Usage
-----

[](#usage)

You can use this package as default `RateLimiter` class:

```
use Beholdr\BackoffLimiter\BackoffLimiter;

$executed = app(BackoffLimiter::class)->attempt(
    'send-sms-'.request()->ip(),
    maxAttempts: 1,
    function () {
        // Send SMS
    }
)

if (! $executed) {
    throw new Exception('Too many requests!');
}
```

Or you can manually control attempts:

```
use Beholdr\BackoffLimiter\BackoffLimiter;

$limiter = app(BackoffLimiter::class);
$key = 'send-sms-'.request()->ip();

if ($limiter->tooManyAttempts($key, 1)) {
    throw new Exception('Too many requests!');
}

$limiter->hit($key)

// Send SMS
```

You can set up:

- **Backoff window**: the time interval during which attempts are counted. Default is `1 hour`
- **Exponent**: determine backoff time duration. Default is `2`

To set custom values pass your values at class creation:

```
$limiter = app(BackoffLimiter::class, ['backoff' => 3*60*60, 'exponent' => 3]);
$limiter->hit(...);
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance76

Regular maintenance activity

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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 ~277 days

Total

4

Last Release

130d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/741973?v=4)[Alexander Shabunevich](/maintainers/beholdr)[@beholdr](https://github.com/beholdr)

---

Top Contributors

[![beholdr](https://avatars.githubusercontent.com/u/741973?v=4)](https://github.com/beholdr "beholdr (6 commits)")

---

Tags

laravelrate-limiterbackoff

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/beholdr-laravel-backoff-limiter/health.svg)

```
[![Health](https://phpackages.com/badges/beholdr-laravel-backoff-limiter/health.svg)](https://phpackages.com/packages/beholdr-laravel-backoff-limiter)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k12.6M135](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k5.4M49](/packages/spatie-laravel-pdf)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[vormkracht10/laravel-mails

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

25060.1k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

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