PHPackages                             bm2ilabs/rate-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bm2ilabs/rate-limiter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bm2ilabs/rate-limiter
=====================

Multi-period rate limiting for Laravel applications with minute, hour, and day limits

1.0.1(1y ago)13MITPHPPHP ^8.0

Since May 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/bm2ilabs/rate-limiter)[ Packagist](https://packagist.org/packages/bm2ilabs/rate-limiter)[ RSS](/packages/bm2ilabs-rate-limiter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

Amineware Rate Limiter
======================

[](#amineware-rate-limiter)

A comprehensive Laravel package for implementing multi-period rate limiting in your application. This package allows you to easily set and enforce rate limits for different time intervals (minute, hour, day) and automatically includes these limits in your API response headers.

Features
--------

[](#features)

- Rate limiting for multiple time periods (minute, hour, day)
- Custom response headers for each period
- Configurable limits through environment variables or config file
- Easy to use middleware
- Support for different identifiers (IP, authenticated user, custom parameter)
- Compatible with Laravel 8.x, 9.x, 10.x, and 11.x

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

[](#installation)

You can install the package via composer:

```
composer require amineware/rate-limiter
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Amineware\RateLimiter\RateLimiterServiceProvider"
```

This will create a `rate-limiter.php` file in your config directory. You can customize the rate limits and other settings in this file.

Basic Usage
-----------

[](#basic-usage)

Add the middleware to your routes:

```
// In routes/api.php
Route::middleware('multi-rate-limit')->group(function () {
    // Your API routes here
});
```

Or apply it to specific routes:

```
Route::get('/endpoint', 'YourController@method')->middleware('multi-rate-limit');
```

Response Headers
----------------

[](#response-headers)

When using this middleware, your API responses will include the following headers:

```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Limit-Hour: 1000
X-RateLimit-Remaining-Hour: 999
X-RateLimit-Limit-Day: 10000
X-RateLimit-Remaining-Day: 9999

```

If a rate limit is exceeded, the response will include:

```
Retry-After:
X-RateLimit-Reset:

```

Advanced Usage
--------------

[](#advanced-usage)

### Using the Facade

[](#using-the-facade)

You can use the facade to manually check or manipulate rate limits:

```
use Amineware\RateLimiter\Facades\MultiPeriodRateLimiter;

// Check remaining attempts
$remaining = MultiPeriodRateLimiter::remaining('minute', $userId);

// Check if too many attempts
if (MultiPeriodRateLimiter::tooManyAttempts('hour', $userId, 100)) {
    // Handle rate limit exceeded
}

// Increment the counter
MultiPeriodRateLimiter::hit('day', $userId);

// Clear rate limits for a key
MultiPeriodRateLimiter::clear('minute', $userId);
```

### Custom Identifiers

[](#custom-identifiers)

By default, the package uses the authenticated user ID or IP address as the identifier. You can customize this in the config file:

```
// In config/rate-limiter.php
'identifiers' => [
    'default' => 'custom',
    'custom_parameter' => 'api_key',
],
```

Environment Variables
---------------------

[](#environment-variables)

You can set rate limits through environment variables:

```
RATE_LIMIT_PER_MINUTE=60
RATE_LIMIT_PER_HOUR=1000
RATE_LIMIT_PER_DAY=10000

```

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance60

Regular maintenance activity

Popularity5

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

Total

2

Last Release

368d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b475cd926c032588a536af89a32f28bbf716296822f9d50cc6c8b0bbd883b45?d=identicon)[bm2ilabs](/maintainers/bm2ilabs)

---

Top Contributors

[![bm2ilabs](https://avatars.githubusercontent.com/u/1745816?v=4)](https://github.com/bm2ilabs "bm2ilabs (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bm2ilabs-rate-limiter/health.svg)

```
[![Health](https://phpackages.com/badges/bm2ilabs-rate-limiter/health.svg)](https://phpackages.com/packages/bm2ilabs-rate-limiter)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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