tp5&cli模式

作用:
有些费时的功能为避免超时超时而使用cli模式
or
定时任务使用cli模式

步骤:
1:项目根目录/application/command.php ,新增配置'app\api\command\Dx'
2:在'app\api\command\Dx' 文件里:

<?php
/**
 * Created by : YqCrm
 * User: lws
 * Date: 2020/7/6
 * Time: 9:35
 */

namespace app\api\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Dx extends Command
{
    protected function configure()
    {
        // 绑定cli操作名
        $this->setName('dx')->setDescription('Here is the remark ');
    }
 
    protected function execute(Input $input, Output $output)
    {
      $output->writeln("helloword");
    }

}

在项目/目录,使用命令php think dx即可

posted @ 2020-07-27 10:06  cl94  阅读(378)  评论(0编辑  收藏  举报