Looking to hire Laravel developers? Try LaraJobs

laravel-schedule maintained by biohazard

Description
Laravel schedule calling multiple commands
Author
Last update
2024/04/10 12:07 (dev-master)
License
Links
Downloads
15

Comments
comments powered by Disqus

Laravel schedule calling multiple commands

composer require biohazard/laravel-schedule

App\Console\Kernel.php

<?php

...
use Biohazard\Kernel as ConsoleKernel;
...

class Kernel extends ConsoleKernel
{
	...

    protected function schedule(Schedule $schedule): void
    {
        $schedule->commands(
            'command1',
            'command2',
            'command3',
        )->name('Name')
            ->storeOutput()
            ->onSuccess(function (Stringable $output) {
                echo 'Schedule task output success '. $output;
            })->onFailure(function (Stringable $output) {
                echo 'Schedule task output failured '. $output;
            })
            ->dailyAt('20:00')
            ->run();

        $schedule->jobs(
            new Job1,
            new Job2,
            new Job3,
        )->name('Name')
            ->dailyAt('21:00')
            ->run();
    }

 	...
}