PHP code example of lajouizakariae / rate-limiter
1. Go to this page and download the library: Download lajouizakariae/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/ */
lajouizakariae / rate-limiter example snippets
use RateLimiter\RateLimiter;
$rateLimiter = new RateLimiter([
'storage' => "file",
'path' => "storage/cache",
]);
$rateLimiter->limitHourly('user:one', 3);
if ($rateLimiter->tooManyAttempts('user:one')) {
# Do Something
}
$rateLimiter->hit('user:one');