Let’s work together

Feel free to send me an email at [email protected]

Research Campus 18
3500 Hasselt
Belgium

Laravel Rate Limiter


Laravel Rate Limiter

While Laravel does support throttling (for routes, and for queues), you might run into use-cases where you need more custom rate limiting logic.

This package contains such logic: https://packagist.org/packages/cschalenborgh/laravel-rate-limiter

The package leverages the default cache provider, configured in your Laravel setup.

 

Here’s an example:

use CschalenborghRateLimiterRateLimiter;
 
$rate_limiter = new RateLimit('action_name', 5, 60); // max 5 times in 60 seconds
 
if ($rate_limiter->check($lock_identifier)) {
    // perform some action
} else {
    // oops.. limit reached
}