Laravel中任務(wù)調(diào)度console使用方法小結(jié)
適用場景:分析數(shù)據(jù)(日志)
php artisan make:console 你的命令類名
示例:
php artisan make:console Check
在\app\Console\Commands目錄下已生成一個(gè)Check.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改為你要的命令名稱
protected $signature = 'check';
此時(shí)還不能在控制臺(tái)中調(diào)用,需要在Kernel.php中注冊。
protected $commands = [ 'App\Console\Commands\Check' ];
你已經(jīng)可以在控制臺(tái)中使用這個(gè)命令了
php artisan check
點(diǎn)評:似乎也沒啥用,因?yàn)閜hp本身也可以不用Laravel框架來使用CLI命令行。
相關(guān)文章
php實(shí)現(xiàn)QQ小程序發(fā)送模板消息功能
QQ小程序群里有伙伴要發(fā)送模板消息的代碼,所以今天給大家分享QQ小程序模板消息發(fā)布,絕對一步一步帶著大家走,每個(gè)細(xì)節(jié)都講到,感興趣的朋友跟隨小編一起看看吧2019-09-09PHP封裝curl的調(diào)用接口及常用函數(shù)詳解
今天小編就為大家分享一篇PHP封裝curl的調(diào)用接口及常用函數(shù)詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-05-05PHP時(shí)間戳格式全部匯總 (獲取時(shí)間、時(shí)間戳)
下面小編就為大家?guī)硪黄狿HP時(shí)間戳格式全部匯總 (獲取時(shí)間、時(shí)間戳)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06thinkphp3.x自定義Action、Model及View的簡單實(shí)現(xiàn)方法
這篇文章主要介紹了thinkphp3.x自定義Action、Model及View的簡單實(shí)現(xiàn)方法,結(jié)合實(shí)例形式詳細(xì)分析了thinkPHP3.x自定義模型、視圖及控制器的具體步驟與相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-05-05php中文驗(yàn)證碼實(shí)現(xiàn)示例分享
這篇文章主要介紹了使用php實(shí)現(xiàn)中文驗(yàn)證碼,代碼簡單,大家可以直接使用2014-01-01typecho統(tǒng)計(jì)博客所有文章的字?jǐn)?shù)實(shí)例詳解
這篇文章主要為大家介紹了typecho統(tǒng)計(jì)博客所有文章的字?jǐn)?shù)實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01