I was not really sure how to implement Laravel's rate limiter so I wrote this in tinkerwell
use Illuminate\Support\Facades\RateLimiter;
foreach(range(0,1000) as $i) {
echo $i;
RateLimiter::hit('testing');
if (RateLimiter::tooManyAttempts('testing', $perMinute = 50)) {
sleep(RateLimiter::availableIn('testing'));
}
}
This might give you idea of how you could incorporate the rate limiter into your loop
'testing' is a unique name for the limiter that allows you to group limits to a service from multiple sources in your code.
the hit function counts the accesses. It will count the requests and limit it to the number per minute.
Then we can test if the limit was reached, and sleep until some more requests are possible.