GlobalLimit
class GlobalLimit extends Limit (View source)
Properties
| mixed | $key | The rate limit signature key. |
from Limit |
| int | $maxAttempts | The maximum number of attempts allowed within the given number of seconds. |
from Limit |
| int | $decaySeconds | The number of seconds until the rate limit is reset. |
from Limit |
| ?callable | $afterCallback | The after callback used to determine if the limiter should be hit. |
from Limit |
| callable | $responseCallback | The response generator callback. |
from Limit |
Methods
Create a new limit instance.
Create a new rate limit using minutes as decay time.
Create a new rate limit using hours as decay time.
Create a new rate limit using days as decay time.
Set the callback to determine if the limiter should be hit.
Details
__construct(int $maxAttempts, int $decaySeconds = 60)
Create a new limit instance.
in
Limit at line 63
static Limit
perSecond(int $maxAttempts, int $decaySeconds = 1)
Create a new rate limit.
in
Limit at line 75
static Limit
perMinute(int $maxAttempts, int $decayMinutes = 1)
Create a new rate limit.
in
Limit at line 87
static Limit
perMinutes(int $decayMinutes, int $maxAttempts)
Create a new rate limit using minutes as decay time.
in
Limit at line 99
static Limit
perHour(int $maxAttempts, int $decayHours = 1)
Create a new rate limit using hours as decay time.
in
Limit at line 111
static Limit
perDay(int $maxAttempts, int $decayDays = 1)
Create a new rate limit using days as decay time.
in
Limit at line 121
static Unlimited
none()
Create a new unlimited rate limit.
in
Limit at line 132
$this
by(mixed $key)
Set the key of the rate limit.
in
Limit at line 145
$this
after(callable $callback)
Set the callback to determine if the limiter should be hit.
in
Limit at line 158
$this
response(callable $callback)
Set the callback that should generate the response when the limit is exceeded.
in
Limit at line 170
string
fallbackKey()
Get a potential fallback key for the limit.
Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.