Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bacherino's avatar

What is throttle ?

I'm trying to use Schedule system on my project and i'm a newbie of laravel when i was started to research for that system but on my shared hosting it has rate limit so i've found out Throttle but i'm getting an error.

What's wrong with that code piece ?

$schedule->call(function () {

 	DB::insert('insert into resp (id,r,t) values (?,?,?)',['1',$data,date("H:i:s")]);

})->everyMinute()->name('import-data')->withoutOverlapping()->throttle(10);

The Error is says doesn't exist but i couldn't find anyway to import that throttle module to my project here is the error;

[2023-03-29 11:30:05] local.ERROR: Method Illuminate\Console\Scheduling\CallbackEvent::throttle does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method Illuminate\Console\Scheduling\CallbackEvent::throttle does not exist. at /home/u0829400/qxtoothpickr/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:113)
[stacktrace]
0 likes
1 reply
LaryAI's avatar
Level 58

The error message suggests that the throttle method does not exist on the CallbackEvent class. This is because the throttle method is not a built-in method in Laravel's scheduling system. Instead, it is provided by the Illuminate\Console\Scheduling\ManagesFrequencies trait, which needs to be included in the class that defines the scheduled task.

To fix the error, you need to include the ManagesFrequencies trait in the class that defines the scheduled task. Here's an example:

use Illuminate\Console\Scheduling\ManagesFrequencies;

class MyScheduledTask
{
    use ManagesFrequencies;

    public function handle()
    {
        // Your scheduled task logic here
    }
}

Then, you can use the throttle method in your scheduled task definition:

$schedule->call(function () {
    DB::insert('insert into resp (id,r,t) values (?,?,?)',['1',$data,date("H:i:s")]);
})
->everyMinute()
->name('import-data')
->withoutOverlapping()
->throttle(10);

This will limit the scheduled task to run a maximum of 10 times per minute. You can adjust the throttle limit as needed.

Please or to participate in this conversation.