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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners