PHP code example of marko / ratelimiter
1. Go to this page and download the library: Download marko/ratelimiter 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/ */
marko / ratelimiter example snippets
use Marko\RateLimiter\Attributes\RateLimit;
use Marko\RateLimiter\Middleware\RateLimitMiddleware;
use Marko\Routing\Attributes\Middleware;
use Marko\Routing\Attributes\Post;
use Marko\Routing\Http\Response;
class LoginController
{
#[Post('/login')]
#[Middleware(RateLimitMiddleware::class)]
#[RateLimit(maxAttempts: 5, decaySeconds: 60, name: 'login')]
public function login(): Response
{
return new Response('OK');
}
}