PHPackages                             beyondcode/laravel-sliding-window-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. beyondcode/laravel-sliding-window-limiter

AbandonedArchivedLibrary

beyondcode/laravel-sliding-window-limiter
=========================================

Sliding window rate limiting for Laravel and Redis

1.1.1(6y ago)424275[1 issues](https://github.com/beyondcode/laravel-sliding-window-limiter/issues)MITPHPPHP ^7.3

Since Sep 16Pushed 6y ago2 watchersCompare

[ Source](https://github.com/beyondcode/laravel-sliding-window-limiter)[ Packagist](https://packagist.org/packages/beyondcode/laravel-sliding-window-limiter)[ Docs](https://github.com/beyondcode/laravel-sliding-window-limiter)[ RSS](/packages/beyondcode-laravel-sliding-window-limiter/feed)WikiDiscussions master Synced yesterday

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

Sliding Time Window Rate Limiter for Laravel
============================================

[](#sliding-time-window-rate-limiter-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e6a6dbb9460cd1e97d8fc8d98088ce84b0f2634160f5ca383cb183d87fd89658/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d736c6964696e672d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-sliding-window-limiter)[![Build Status](https://camo.githubusercontent.com/33639cd4bbcb22643b2abe9a12bd5b41dab96a3973138157c0d3489148b3ea80/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6265796f6e64636f64652f6c61726176656c2d736c6964696e672d77696e646f772d6c696d697465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/beyondcode/laravel-sliding-window-limiter)[![Quality Score](https://camo.githubusercontent.com/a15b37d4ea5859c6be67d525d39e55c6d96b3d8d822a4d0c334b45fc8f0cdc95/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6265796f6e64636f64652f6c61726176656c2d736c6964696e672d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/beyondcode/laravel-sliding-window-limiter)[![Total Downloads](https://camo.githubusercontent.com/0946c08651a964372d296cc448a847e75de9047a048dfbdb16d54bb2e0879445/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d736c6964696e672d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-sliding-window-limiter)

This package allows you to easily create and validate rate limiting using the sliding window algorithm (in a memory efficient way).

This package makes use of Redis' atomic requests.

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

[](#installation)

You can install the package via composer:

```
composer require beyondcode/laravel-sliding-window-limiter
```

Usage
-----

[](#usage)

You can create a new limiter instance by calling the `create` method and pass it a CarbonInterval that represents the window of time, that will be used for the limiter. The second argument is the maximum number of requests/attempts that your limiter will accept in that given time frame.

```
$limiter = SlidingWindowLimiter::create(CarbonInterval::hour(1), 100);
```

### Specifying custom intervals

[](#specifying-custom-intervals)

By default, all attempts to the limiter will be grouped down to the nearest minute. If you need a more fine-grained control over the interval, you can specify it as a third parameter:

```
$limiter = SlidingWindowLimiter::create(CarbonInterval::minute(1), 100, CarbonInterval::second());
```

### Running attempts against your limiter

[](#running-attempts-against-your-limiter)

Once your limiter is created, you can perform attempts against it to see if the call is within the usage limits that you specified. Since your limiter can be used for multiple resources, you need to pass the resource that you want to attempt the call for in the `attempt` method call.

```
$limiter->attempt('user_1');
```

### Getting the usage count

[](#getting-the-usage-count)

When you want to read the number of attempts that were made for a given resource, you may call the `getUsage` method.

**Note:** This method will not return the number of attempts, but only the number of successful attempts.

```
$count = $limiter->getUsage('user_1');
```

### Reset the limiter

[](#reset-the-limiter)

If you want to reset the attempts for a specific resource, you may call the `reset` method on the limiter instance. This will reset the TTL to the given time frame and re-allow new attempts.

```
$limiter->reset('user_1');
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Marcel Pociot](https://github.com/mpociot)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

2423d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/863e91ca13b8c4031f202c0eee4f06b3a4352f92cf9cd397b03609b20247ed16?d=identicon)[beyondcode](/maintainers/beyondcode)

---

Top Contributors

[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (5 commits)")

---

Tags

beyondcodelaravel-sliding-window-limiter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/beyondcode-laravel-sliding-window-limiter/health.svg)

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

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M225](/packages/laravel-horizon)[beyondcode/laravel-query-detector

Laravel N+1 Query Detector

2.0k6.7M12](/packages/beyondcode-laravel-query-detector)[beyondcode/laravel-self-diagnosis

Perform various self diagnosis tests on your Laravel application.

1.5k1.2M4](/packages/beyondcode-laravel-self-diagnosis)[beyondcode/laravel-mailbox

Handle incoming emails in your Laravel application.

1.1k1.0M4](/packages/beyondcode-laravel-mailbox)[beyondcode/laravel-server-timing

Add Server-Timing header information from within your Laravel apps.

5712.0M1](/packages/beyondcode-laravel-server-timing)

PHPackages © 2026

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