avtonom/limit-number-calls-bundle
Security Voter, AppKernel integration) are not directly transferable.Security Voter and AppKernel integration are Symfony-specific. Laravel’s middleware or policy-based authorization (e.g., Gate) could replace these.avtonom:limit-calls:status) would need Laravel-specific facades (e.g., Artisan::command()).maximum_number, time_period) can be abstracted into a Laravel service provider.lnc:{rule}:{value}).Voter with Laravel middleware or a RateLimit policy.AuthorizationChecker). Mitigate by:
Security Voter in Laravel, or just the rate-limiting logic?sms_group) needed, or can simpler rules suffice?spatie/laravel-rate-limiter, laravel-throttle) meet needs with less effort?predis/predis or Laravel’s Redis driver.Security Voter with:
RateLimitMiddleware).SmsPolicy::checkRateLimit()).Artisan commands.RateLimiter).Rule, Storage classes) from Symfony dependencies.class RateLimiter {
protected $redis;
protected $rules;
public function __construct(Redis $redis, array $rules) {
$this->redis = $redis;
$this->rules = $rules;
}
public function check(string $rule, string $value): bool {
// Implement logic from avtonom/limit-number-calls-bundle
}
}
RateLimiter in a Service Provider:
$this->app->singleton(RateLimiter::class, function ($app) {
return new RateLimiter(
$app['redis'],
config('rate_limiter.rules')
);
});
public function handle($request, Closure $next) {
$value = $request->ip(); // or custom logic
if (!$this->rateLimiter->check('login_attempt', $value)) {
return response('Too Many Requests', 429);
}
return $next($request);
}
Artisan commands:
Artisan::command('rate-limit:status', function () {
// Fetch and display blocked values from Redis
});
RateLimiter class.lnc:{rule}:{value}) but adapt to Laravel’s Redis conventions.config.yaml/parameters.yaml to Laravel’s config/rate_limiter.php:
'rules' => [
'sms_1m_10_rule' => [
'time_period' => 60000000, // microseconds
'maximum_number' => 10,
'blocking_duration' => 600,
'subject_method' => ['getParameter', 'phone'],
],
],
Gate or custom middleware.RateLimiter class without Laravel integration.Log facade to track blocked requests and rule violations:
Log::warning("Rate limit exceeded for rule {$rule}, value {$value}");
php artisan rate-limit:status
RateLimiter class, middleware, and CLI tools.array + periodic Redis sync).redis-cli --bigkeys
How can I help you explore Laravel packages today?