Ratelimiter
Less than 1 minute
Ratelimiter
Class Ratelimiter.
Middleware 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
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 Sun, 01 Mar 2026 09:22:26 +0000