Using the Laravel task scheduler I have created a number of tasks in Kernel.php
e.g:
$schedule->command(\'some:command\')
->daily();
$sche
There's actually no support out of the box for this, unfortunately. What you'll have to do is extend the artisan schedule
command and add a list
feature. Thankfully there's a simple class you can run:
schedule = $schedule;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$events = array_map(function ($event) {
return [
'cron' => $event->expression,
'command' => static::fixupCommand($event->command),
];
}, $this->schedule->events());
$this->table(
['Cron', 'Command'],
$events
);
}
/**
* If it's an artisan command, strip off the PHP
*
* @param $command
* @return string
*/
protected static function fixupCommand($command)
{
$parts = explode(' ', $command);
if (count($parts) > 2 && $parts[1] === "'artisan'") {
array_shift($parts);
}
return implode(' ', $parts);
}
}
This will provide you with a php artisan schedule:list
. Now that's not exactly what you need, but then you can easily get this list from within your Laravel stack by executing:
Artisan::call('schedule:list');
And that will provide you with a list of the schedule commands.
Of course, don't forget to inject the Facade
: use Illuminate\Support\Facades\Artisan;