artisansdk/ratelimiter
Laravel rate limiting package providing flexible throttling for routes and actions with configurable rules, storage drivers, and easy middleware integration. Helps protect APIs from abuse, control request bursts, and manage per-user or per-IP limits with clear, adjustable settings.
Strengths:
Weaknesses:
laravel-debugbar). Custom instrumentation is still required.RateLimiter facade or third-party circuit breakers (e.g., spatie/laravel-circuitbreaker), which could complement rate limiting during failures.Key Use Cases:
/api/v1/users) with burst traffic patterns./login, /forgot-password)./billing/webhooks) to enforce tiered limits.Laravel Ecosystem Compatibility:
register/boot methods, maintaining best practices for package integration..env variables for dynamic tuning (e.g., RATE_LIMIT=60/second), enabling environment-specific configurations.Dependencies:
config/database.php.predis or php-redis for Redis).Illuminate\Support\Facades or Illuminate\Http components, though no breaking changes are noted.Customization Points:
capacity and refill_rate per route remain unchanged.429 Too Many Requests responses via middleware handle() method.High-Risk Areas:
SETNX or Lua scripts), race conditions may inflate token counts, especially in Laravel 13’s more concurrent request-handling model.Mitigation Strategies:
useAtomicOperations() flag.spatie/laravel-horizon for queue workers) to ensure bucket refill behavior is stable.Problem exceptions).app()->bind() changes, updated Route caching) to catch integration issues early.Open Questions:
Illuminate\Redis\Connections\Connection changes affect this.Illuminate\Http\Client) if used for async rate-limiting checks?Laravel Version Compatibility:
composer.json constraints:
"require": {
"laravel/framework": "^13.0",
"artisansdk/ratelimiter": "^1.2"
}
Tech Stack Synergy:
laravel-redis v13 for consistency.mysql/pgsql with proper indexing on the key column (Laravel 13’s query builder may optimize this further).horizon or laravel-queues).Alternatives Considered:
spatie/laravel-rate-limiter: Fixed-window algorithm (less burst-friendly) but may integrate better with Laravel 13’s new scheduling system.digitalcreative/laravel-ratelimiter: Token bucket alternative (may lack leaky bucket features or Laravel 13 support).app()->singleton()).Assessment Phase:
throttle middleware, or Laravel 10’s RateLimiter)./livewire/updates, /api/resources).Proof of Concept:
composer require artisansdk/ratelimiter:^1.2.config/ratelimiter.php (publish config with php artisan vendor:publish --provider="ArtisanSdk\RateLimiter\RateLimiterServiceProvider").Route::middleware([\ArtisanSdk\RateLimiter\Middleware\RateLimiterMiddleware::class])
->get('/test', function () { return response()->json(['status' => 'ok']); });
Phased Rollout:
throttle middleware with RateLimiterMiddleware for critical Laravel 13 endpoints (e.g., /api/v1/resources).capacity/refill_rate based on load tests with Laravel 13’s optimized request handling.Configuration Example (Laravel 13):
// config/ratelimiter.php
'limits' => [
'auth.login' => [
'driver' => 'redis',
'capacity' => 5,
'refill_rate' => 1,
'key' => 'rate_limit_auth_login_{$ip}',
'middleware' => ['web
How can I help you explore Laravel packages today?