PHP
发布时间:2019-11-11 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Laravel中任务调度console使用方法小结,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
适用场景:分析数据(日志)
php;gutter:true;">
php artisan make:console
你的命令类名
示例:
php;gutter:true;">
php artisan make:console
check
在\app\Console\Commands目录下已生成一个check.php文件
php;gutter:true;">
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;gutter:true;">
protected $signature = '
check';
此时还不能在控制台中调用,需要在Kernel.php中注册。
php;gutter:true;">
protected $commands = [
'App\Console\Commands\
check'
];
你已经可以在控制台中使用这个命令了
点评:似乎也没啥用,因为php本身也可以不用Laravel框架来使用CLI命令行。
大佬总结
以上是大佬教程为你收集整理的Laravel中任务调度console使用方法小结全部内容,希望文章能够帮你解决Laravel中任务调度console使用方法小结所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。