zoukankan      html  css  js  c++  java
  • thinkphp6自定义指令

    创建自定义指令操作步骤:

    第一步:运行指令

    php think make:command Auto auto

    即可看到在 app\command 目录生成的 Auto.php 

    修改里面的代码:

    <?php
    declare (strict_types = 1);
    
    namespace app\command;
    
    use think\console\Command;
    use think\console\Input;
    use think\console\input\Argument;
    use think\console\input\Option;
    use think\console\Output;
    
    class Auto extends Command
    {
        protected function configure()
        {
            // 命令行参数
            $this->addArgument('a', Argument::REQUIRED); // 必须参数
            $this->addArgument('b', Argument::REQUIRED); // 必须参数
            $this->setName('auto');
            $this->setDescription('生成模块');
        }
    
        protected function execute(Input $input, Output $output)
        {
            $a = $input->getArgument('a');
            $b = $input->getArgument('b');
            echo $a.'+'.$b;
        }
    
    }

    第二步:修改 config/console.php 文件

    <?php
    return [
        'commands' => [
            'auto' => 'app\command\Auto',
        ]
    ];

    第三步:测试

    php think auto 100 200

    结果:

  • 相关阅读:
    MySql 数据类型
    MySql 数据库的增删改
    MySql 联合查询
    Mysql 库的管理 --->>>>DDL
    MySql 子查询
    MySql 分页查询
    sql99语法的连接查询
    MySql 连接查询
    MySql 分组函数
    jQ处理页面中尺寸过大的图片
  • 原文地址:https://www.cnblogs.com/e0yu/p/15751973.html
Copyright © 2011-2022 走看看