### make:command
$ php artisan make:command TestCommand
app/Console/Commands/TestCommand.php
protected $signature = 'command:testcommand';
public function handle()
{
//
echo "test command execute!";
}
app/Console/Kernel.php
protected $commands = [
//
\App\Console\Commands\TestCommand::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('command:testcommand')->daily();
}
### command実行
$ php artisan list;
$ php artisan command:testcommand;
$ crontab -e
実用性から考えると、バッチ処理はcronで直書きの方が楽そうですが、Githubなどで全てソースコードで管理したい場合は使えるかもしれません。どちらが良いかは好みやコンセンサスでしょうか。