| Package Data | |
|---|---|
| Maintainer Username: | rogervila |
| Maintainer Contact: | rogervila@me.com (Roger Vilà) |
| Package Create Date: | 2020-11-10 |
| Package Last Update: | 2024-06-03 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-04 15:09:16 |
| Package Statistics | |
|---|---|
| Total Downloads: | 55,747 |
| Monthly Downloads: | 1,970 |
| Daily Downloads: | 80 |
| Total Stars: | 16 |
| Total Watchers: | 1 |
| Total Forks: | 2 |
| Total Open Issues: | 1 |
This package contains Lumen port of Laravel's ThrottleRequests middleware
composer require rogervila/lumen-rate-limiting
AppServiceProvider and AuthServiceProvider are uncommented on bootstrap/app.php
$app->register(App\Providers\AppServiceProvider::class);
$app->register(App\Providers\AuthServiceProvider::class);
AppServiceProvider boot method/**
* Configure global rate limiter
*
* @return void
*/
public function boot()
{
app(\Illuminate\Cache\RateLimiter::class)->for('global', function () {
return \Illuminate\Cache\RateLimiting\Limit::perMinute(60)->by(request()->ip());
});
}
bootstrap/app.php
$app->routeMiddleware([
'throttle' => \LumenRateLimiting\ThrottleRequests::class,
]);
bootstrap/app.php
$app->router->group([
'namespace' => 'App\Http\Controllers',
'middleware' => 'throttle:global',
], function ($router) {
require __DIR__ . '/../routes/web.php';
});
The middleware can be placed on specific routes instead of globally, as defined on the official documentation.
This project is open-sourced software licensed under the MIT license.