Laravel中任務(wù)調(diào)度console使用方法小結(jié)
適用場(chǎng)景:分析數(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中注冊(cè)。
protected $commands = [
'App\Console\Commands\Check'
];
你已經(jīng)可以在控制臺(tái)中使用這個(gè)命令了
php artisan check
點(diǎn)評(píng):似乎也沒啥用,因?yàn)閜hp本身也可以不用Laravel框架來(lái)使用CLI命令行。
相關(guān)文章
PHP中isset()和unset()函數(shù)的用法小結(jié)
本篇文章主要是對(duì)PHP中isset()和unset()函數(shù)的用法進(jìn)行了詳細(xì)的介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-03-03
thinkphp模板賦值與替換實(shí)例簡(jiǎn)述
這篇文章主要介紹了thinkphp模板賦值與替換的方法,以實(shí)例形式簡(jiǎn)述了模板復(fù)制的兩種簡(jiǎn)單方法,以及模板替換中的特殊字符串說(shuō)明與用法實(shí)例,是使用頻率比較高的技巧,需要的朋友可以參考下2014-11-11
PHP實(shí)現(xiàn)采集中國(guó)天氣網(wǎng)未來(lái)7天天氣
這篇文章主要介紹了PHP實(shí)現(xiàn)采集中國(guó)天氣網(wǎng)未來(lái)7天天氣方法,本文詳細(xì)的講解了需求的實(shí)現(xiàn),也可以做為學(xué)習(xí)PHP采集的入門教程,需要的朋友可以參考下2014-10-10
PHP與Java進(jìn)行通信的實(shí)現(xiàn)方法
這篇文章主要介紹了php與java通信的實(shí)現(xiàn)方法,需要的朋友可以參考下2013-10-10
基于ThinkPHP5框架使用QueryList爬取并存入mysql數(shù)據(jù)庫(kù)操作示例
這篇文章主要介紹了基于ThinkPHP5框架使用QueryList爬取并存入mysql數(shù)據(jù)庫(kù)操作,結(jié)合實(shí)例形式分析了thinkPHP5框架整合QueryList爬取數(shù)據(jù)存入mysql相關(guān)操作技巧及注意事項(xiàng),需要的朋友可以參考下2019-05-05
使用一個(gè)for循環(huán)將N*N的二維數(shù)組的所有值置1實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇使用一個(gè)for循環(huán)將N*N的二維數(shù)組的所有值置1實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-05-05

