Thinkphp command使用
2023-03-29 23:03:03
235
{{single.collect_count}}

第一步,配置command.php文件,目录在application/command.php

<?phpreturn ['app\home\command\Test',];

第二步,建立命令类文件,新建application/home/command/Test.php

<?phpnamespace app\home\command;use think\console\Command;use think\console\Input;use think\console\Output;class Test extends Command{protected function configure(){$this->setName('test')->setDescription('任务描述');}protected function execute(Input $input, Output $output){$output->writeln('请求时间:'.date('Y-m-d H:i:s'));//处理过程………………$output->writeln("TestCommand:");}}

第三步,打开cmd,进入到项目目录D:\phpstudy_pro\WWW\newweb
执行 php think Test

补充 thinkphp command
带参数
docker exec -it -u www-data cli /usr/local/bin/php /data/website/latest/abthink Test add_order
接收参数

protected function configure(){$this->setName('Test')->setDescription('数据上报');$this->addArgument("action", Argument::REQUIRED, "The name of the class");}protected function execute(Input $input, Output $output){$output->writeln('执行前---' . date("Y-m-d H:i:s", time()) . '<br>');$type = $input->getArgument("action");}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}