Looking to hire Laravel developers? Try LaraJobs

laravel-rate-limiter maintained by cschalenborgh

Description
Rate limiter for Laravel
Last update
2020/04/17 17:44 (dev-master)
License
Links
Downloads
716

Comments
comments powered by Disqus

Rate Limiter package for Laravel

Latest Version on Packagist Build Status Code Coverage (GitHub) StyleCI Total Downloads License: MIT

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
}