適用場景:分析數據(日誌)php
php artisan make:console 你的命令類名
示例:bash
php artisan make:console Check
在\app\Console\Commands目錄下已生成一個Check.php文件app
<?php namespace App\Console\Commands; use Illuminate\Console\Command; class Check extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'command:name'; /** * 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() { // } }
你能夠把$signature改成你要的命令名稱框架
protected $signature = 'check';
此時還不能在控制檯中調用,須要在Kernel.php中註冊。spa
protected $commands = [ 'App\Console\Commands\Check' ];
你已經能夠在控制檯中使用這個命令了命令行
php artisan check
點評:彷佛也沒啥用,由於php自己也能夠不用Laravel框架來使用CLI命令行。日誌