Laravel中任務調度console使用方法小結
更新時間:2017年05月07日 11:36:03 作者:編程老頭
這篇文章主要給大家簡單介紹了Laravel中任務調度console使用方法,并附上一個簡單的示例,希望對大家學習使用console能夠有所幫助
適用場景:分析數(shù)據(jù)(日志)
php artisan make:console 你的命令類名
示例:
php artisan make:console Check
在\app\Console\Commands目錄下已生成一個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';
此時還不能在控制臺中調用,需要在Kernel.php中注冊。
protected $commands = [
'App\Console\Commands\Check'
];
你已經(jīng)可以在控制臺中使用這個命令了
php artisan check
點評:似乎也沒啥用,因為php本身也可以不用Laravel框架來使用CLI命令行。
相關文章
PHP中isset()和unset()函數(shù)的用法小結
本篇文章主要是對PHP中isset()和unset()函數(shù)的用法進行了詳細的介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-03-03
PHP實現(xiàn)采集中國天氣網(wǎng)未來7天天氣
這篇文章主要介紹了PHP實現(xiàn)采集中國天氣網(wǎng)未來7天天氣方法,本文詳細的講解了需求的實現(xiàn),也可以做為學習PHP采集的入門教程,需要的朋友可以參考下2014-10-10
基于ThinkPHP5框架使用QueryList爬取并存入mysql數(shù)據(jù)庫操作示例
這篇文章主要介紹了基于ThinkPHP5框架使用QueryList爬取并存入mysql數(shù)據(jù)庫操作,結合實例形式分析了thinkPHP5框架整合QueryList爬取數(shù)據(jù)存入mysql相關操作技巧及注意事項,需要的朋友可以參考下2019-05-05
使用一個for循環(huán)將N*N的二維數(shù)組的所有值置1實現(xiàn)方法
下面小編就為大家?guī)硪黄褂靡粋€for循環(huán)將N*N的二維數(shù)組的所有值置1實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-05-05

