首页 > 其他 > 详细

lumen Console Commands

时间:2016-05-05 15:48:23      阅读:987      评论:0      收藏:0      [点我收藏+]

1.在app->Console->Commands中新增类 继承  Illuminate\Console\Command

<?php
 
namespace App\Console\Commands;
 
use Illuminate\Console\Command;
 
class TestCommand extends Command
{
    /**
     * 命令行执行命令
     * @var string
     */
    protected $signature = ‘test_command‘;
 
    /**
     * 命令描述
     *
     * @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()
    {
        //这里编写需要执行的动作
    }
}

2.在app->Console->Kernel.php中 Commands 数组中加入当前命令类TestCommand::class

protected $commands = [
    TestCommand::class,
];

3.查看命令

php artisan list

技术分享

4 执行test_command命令

     php artisan test_command

lumen Console Commands

原文:http://www.cnblogs.com/xxrl-c/p/5462159.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!