《PHP實戰:Laravel中任務調度console使用方法小結》要點:
本文介紹了PHP實戰:Laravel中任務調度console使用方法小結,希望對您有用。如果有疑問,可以聯系我們。
適用場景:分析數據(日志)PHP編程
php artisan make:console 你的命令類名
示例:PHP編程
php artisan make:console Check
在\app\Console\Commands目錄下已生成一個Check.php文件PHP編程
<?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改為你要的命令名稱PHP編程
protected $signature = 'check';
此時還不能在控制臺中調用,需要在Kernel.php中注冊.PHP編程
protected $commands = [ 'App\Console\Commands\Check' ];
你已經可以在控制臺中使用這個命令了PHP編程
php artisan check
點評:似乎也沒啥用,因為php本身也可以不用Laravel框架來使用CLI命令行.PHP編程
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/827.html