cschalenborgh / laravel-rate-limiter
Rate limiter for Laravel
1.0.3
2020-04-17 15:44 UTC
Requires
- php: >=7.1
- illuminate/cache: ~5.8.0 || ^6.0 || ^7.0
- illuminate/config: ~5.8.0 || ^6.0 || ^7.0
- illuminate/container: ~5.8.0 || ^6.0 || ^7.0
- illuminate/support: ~5.8.0 || ^6.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-12-18 02:44:50 UTC
README
Description
You can use this package to easily rate limiter specific logic in your Laravel application, from Guzzle requests, to more specific application logic. This package is based on https://github.com/touhonoob/RateLimit.
Installation
You can install the package via composer:
composer require cschalenborgh/laravel-rate-limiter
The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:
'providers' => [ // ... Cschalenborgh\RateLimiter\RateLimiterServiceProvider::class, ];
Usage
use Cschalenborgh\RateLimiter\RateLimiter; $rate_limiter = new RateLimiter('action_name', 5, 60); // max 5 times in 60 seconds if ($rate_limiter->check($lock_identifier)) { // perform some action } else { // oops.. limit reached }