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(2mo ago)25.6kMITPHPPHP ^8.1CI failing

Since Dec 21Pushed 2mo 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 3w 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

43

—

FairBetter than 90% of packages

Maintenance83

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

85d 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-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k9.9M90](/packages/dedoc-scramble)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[spatie/laravel-passkeys

Use passkeys in your Laravel app

470755.5k32](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[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.

32837.0k](/packages/sunchayn-nimbus)

PHPackages © 2026

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