PHP code example of cschalenborgh / laravel-rate-limiter

1. Go to this page and download the library: Download cschalenborgh/laravel-rate-limiter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cschalenborgh / laravel-rate-limiter example snippets


'providers' => [
    // ...
    Cschalenborgh\RateLimiter\RateLimiterServiceProvider::class,
];

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
}