What are you're trying to achieve in the first place?
As for me, I'm not ready to fix AI generated problems, people generated are more than enough...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
use Illuminate\Cache\RateLimiter;
use Illuminate\Support\Facades\RateLimiter as RateLimiterFacade;
// In AppServiceProvider boot method:
RateLimiterFacade::for('mailing-list', function (object $job) {
return $job->user->rateLimit(5)->perMinute(); // A - defined first time
// Or a global limit:
// return Limit::perMinute(5);
});
class SendUserEmail implements ShouldQueue
{
// ...
public function middleware(): array
{
return [
// Define the rate limit: e.g., 5 emails per minute
(new RateLimited('mailing-list'))
->allow(5)->every(60) // B - why do this again?
// If rate limited, release the job back for 60 seconds
->releaseAfterSeconds(60),
];
}
}
Please or to participate in this conversation.