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

ActiveLibrary

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

Rate limiter with exponential backoff for Laravel.

v0.1.2(1y ago)25.1k↓100%MITPHPPHP ^8.1CI failing

Since Dec 21Pushed 1y 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 1mo ago

READMEChangelog (1)Dependencies (12)Versions (4)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

33

—

LowBetter than 75% of packages

Maintenance46

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Total

3

Last Release

413d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c2acd8f17973138881ff45f60bfa042b6bfa0623af69be06660992aea22c358?d=identicon)[beholdr](/maintainers/beholdr)

---

Top Contributors

[![beholdr](https://avatars.githubusercontent.com/u/741973?v=4)](https://github.com/beholdr "beholdr (5 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

[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)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

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