Ratelimiter
Less than 1 minute
Ratelimiter
Class Ratelimiter.
class Ratelimiter implements \Hazaar\Controller\Middleware\MiddlewareMiddleware implementation for rate limiting incoming requests. This class is intended to be used within the Hazaar Framework to control the rate at which clients can access certain routes or controllers.
Implements the Middleware interface.
Properties
rateLimiter
Runtime rate-limiter utility used to track and validate request quotas.
private UtilRateLimiter $rateLimiterMethods
__construct
Constructs a new rate limiter middleware instance.
public __construct(int $requests, int $seconds, string $backend = 'cache'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$requests | int | the maximum number of allowed requests within the specified time window |
$seconds | int | the duration of the time window in seconds |
$backend | string | the backend storage mechanism to use for rate limiting (default is 'file') |
handle
Handles the incoming request and applies rate limiting.
public handle(Request $request, callable $next, mixed $args): ResponseParameters
| Parameter | Type | Description |
|---|---|---|
$request | Request | the incoming HTTP request |
$next | callable | the next middleware or handler to call |
$args | mixed |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000