
# php artisan make:console UpdateHogeFeed --command="updateHoge"
コマンドを作る
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class UpdateHogeFeed extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'updateHoge';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
echo 'Successだよ';
}
}
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\UpdateHogeFeed::class, ←●追加
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('updateHoge')->weeklyOn(1, '2:00'); // ←●追加 毎週月曜日2時に実行
}
・・・
# php artisan updateHoge Successだよ
コマンドができたな🐱

