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 Cschalenborgh\RateLimiter\RateLimiter;
 
$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
}

Freelance webdeveloper & Entreprenerd Specialized in developing, scaling and optimizing of succesful web applications, community websites and small/corporate business websites using technologies such as PHP 5, Laravel, HTML5, jQuery, .. Trying to find optimal Google love for every website. I'm always interested and open for new business opportunities.