The rate limiter provides a small request-throttling layer and a matching middleware.
use Myxa\RateLimit\RateLimitServiceProvider;
$app->register(new RateLimitServiceProvider());$limiter = $app->make(\Myxa\RateLimit\RateLimiter::class);
$result = $limiter->consume('login:127.0.0.1', 5, 60);
if (!$result->allowed) {
// reject request
}use Myxa\Support\Facades\Route;
Route::get('/api/users', [UserController::class, 'index'])
->middleware(\Myxa\Middleware\RateLimitMiddleware::using(60, 60, 'api'));- the default store is filesystem-backed unless you bind another store
- exceeded limits throw
TooManyRequestsException - the default HTTP exception handler adds rate-limit headers automatically