PHP code example of unetway / rate-limiting
1. Go to this page and download the library: Download unetway/rate-limiting 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/ */
unetway / rate-limiting example snippets
$rateLimit = new RateLimitingService([
'maxCallsLimit' => 10,
'timePeriod' => 86400
]);
if (!$rateLimit->check()) {
http_response_code(429);
exit();
}
$rateLimit = new RateLimitingService([
'maxCallsLimit' => 10,
'timePeriod' => 86400
]);
if (!$rateLimit->check()) {
echo "Вы уже отправили форму ${$rateLimit->total()} раз!";
}