Thinkphp Shell 执行操作

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

<?php
return [
    'app\home\command\ClassName',
];

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

<?php
namespace app\common\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class ClassNameextends Command
{
    protected function configure()
    {
        $this->setName('commission')->setDescription('');
    }
 
    protected function execute(Input $input, Output $output)
    {
        $output->writeln('执行成功');
    }
}

第三步,测试-命令帮助-命令行下运行

php think class_name //对应命令类名

第四步,宝塔添加Shell命令

cd /www/wwwroot/project_path
php think class_name

  

posted @ 2025-05-11 22:06  鲨鱼大王  阅读(67)  评论(0)    收藏  举报