PHPackages                             beyondcode/laravel-fixed-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. [HTTP &amp; Networking](/categories/http)
4. /
5. beyondcode/laravel-fixed-window-limiter

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

beyondcode/laravel-fixed-window-limiter
=======================================

Fixed window rate limiting for Laravel and Redis

1.2.0(6y ago)67690MITPHPPHP ^7.3

Since Apr 7Pushed 6y ago2 watchersCompare

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

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

Fixed Time Window Rate Limiter for Laravel
==========================================

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/032e4fa2d333946684a3f7480d141f80b176ac6bd2e8e43d885bc188a3e4e595/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6265796f6e64636f64652f6c61726176656c2d66697865642d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-fixed-window-limiter)[![Build Status](https://camo.githubusercontent.com/dfa10ffdce16959376fe084e4259682d0b38276e26336c1457f3056d24f95298/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6265796f6e64636f64652f6c61726176656c2d66697865642d77696e646f772d6c696d697465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/beyondcode/laravel-fixed-window-limiter)[![Quality Score](https://camo.githubusercontent.com/ffb191d2e32813f5ae13b6dd59f8547abcfac691804cc55d1c4fedd1612396ac/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6265796f6e64636f64652f6c61726176656c2d66697865642d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/beyondcode/laravel-fixed-window-limiter)[![Total Downloads](https://camo.githubusercontent.com/00dcc61581183a2b1b80792c0752b62f31f94f351b636cec0bbb2bec4e1ebda9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6265796f6e64636f64652f6c61726176656c2d66697865642d77696e646f772d6c696d697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beyondcode/laravel-fixed-window-limiter)

This package allows you to easily create and validate rate limiting using the fixed window algorithm.

This package makes use of Redis' atomic requests.

[![](https://camo.githubusercontent.com/1387a5d17dca91276468eaa71355299d0c83370d3a804701fc968ed211a9d750/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6c696d697465722f6c696d697465722e706e67)](https://camo.githubusercontent.com/1387a5d17dca91276468eaa71355299d0c83370d3a804701fc968ed211a9d750/68747470733a2f2f6265796f6e64636f2e64652f6769746875622f6c696d697465722f6c696d697465722e706e67)

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

[](#installation)

You can install the package via composer:

```
composer require beyondcode/laravel-fixed-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 = FixedWindowLimiter::create(CarbonInterval::second(2), 2);
```

### 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. Use the `getRealUsage` method, if you want to see all attempts, including those that were rejected.

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

Or as mentioned, to get the real usage of all attempts for the resource:

```
$count = $limiter->getRealUsage('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');
```

### Additional data

[](#additional-data)

Sometimes you might want to store additional data inside of the resource hash in Redis. You can pass the initial data to the `reset` method.

```
$limiter->reset('user_1', [
    'key' => 'value'
]);
```

In order to retrieve the data, you may use the `getAdditionalData` method.

```
$value = $limiter->getAdditionalData('user_1', 'key');
```

### 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

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Total

4

Last Release

2302d 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 (12 commits)")

---

Tags

beyondcodelaravel-fixed-window-limiter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/beyondcode-laravel-fixed-window-limiter/health.svg)](https://phpackages.com/packages/beyondcode-laravel-fixed-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)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)

PHPackages © 2026

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