PHP code example of naf / rate-limit
1. Go to this page and download the library: Download naf/rate-limit 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/ */
naf / rate-limit example snippets
$decision = guard()->rateLimit('export:account:' . $accountId, 10, 60);
if (!$decision['allowed']) {
return json(['error' => 'Too many requests'], 429)
->withHeader('Retry-After', (string) $decision['retry_after']);
}