1首先我们先创建一个Test.php测试任务
php artisan make:command Test
2.创建完成后会在app/Console/Commands/目录下,如图
3.打开Test.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
class Test extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test';//命令名称,待会调用php artisan test就会执行
/**
* The console command description.
*
* @var string
*/
protected $description = '这是一条测试任务';//命令描述没啥用
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
*