Category: Laravel, Laravel, api, api

Sometimes you need to control how many times a logic is called, specially when contacting external APIs, to avoid hard errors on requests and stopping the whole application.

There is a Rate Limiter, and you can use it to throttle a callback, or anything really. But why stopping there if we can further create a helper to save us more lines?

It will accept the key needed for the Rate Limiter and the callback itself we want to execute.

For example, we need to send a message to another user, but avoid spamming users with multiple messages across the application.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners