<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 自定義指令 ## 創建自定義指令 第一步,創建一個自定義命令類文件,新建`application/common/command/Hello.php` ``` <?php namespace app\common\command; use think\console\Command; use think\console\Input; use think\console\input\Argument; use think\console\input\Option; use think\console\Output; class Hello extends Command { ? ? protected function configure() ? ? { ? ? ? ? $this->setName('hello') ->addArgument('name', Argument::OPTIONAL, "your name") ->addOption('city', null, Option::VALUE_REQUIRED, 'city name') ->setDescription('Say Hello'); ? ? } ? ? protected function execute(Input $input, Output $output) ? ? { $name = trim($input->getArgument('name')); $name = $name ?: 'thinkphp'; if ($input->hasOption('city')) { $city = PHP_EOL . 'From ' . $input->getOption('city'); } else { $city = ''; } ? ? ? ? $output->writeln("Hello," . $name . '!' . $city); ? ? } } ``` 這個文件定義了一個叫`hello`的命令,并設置了一個`name`參數和一個`city`選項。 第二步,配置`application/command.php`文件 ``` <?php return [ ? ? 'app\common\command\Hello', ]; ``` 第三步,測試-命令幫助-命令行下運行 ``` php think ``` 輸出 ``` Think Console version 0.1 Usage: ? command [options] [arguments] Options: ? -h, --help ? ? ? ? ? ?Display this help message ? -V, --version ? ? ? ? Display this console version ? -q, --quiet ? ? ? ? ? Do not output any message ? ? ? --ansi ? ? ? ? ? ?Force ANSI output ? ? ? --no-ansi ? ? ? ? Disable ANSI output ? -n, --no-interaction ?Do not ask any interactive question ? -v|vv|vvv, --verbose ?Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: ? build ? ? ? ? ? ? ?Build Application Dirs ? clear ? ? ? ? ? ? ?Clear runtime file hello? ? ? ? ? ? ? Say Hello ? help ? ? ? ? ? ? ? Displays help for a command ? list ? ? ? ? ? ? ? Lists commands ?make ? make:controller ? ?Create a new resource controller class ? make:model ? ? ? ? Create a new model class ?optimize ? optimize:autoload ?Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production. ? optimize:config ? ?Build config and common file cache. ? optimize:schema ? ?Build database schema cache. ``` 第四步,運行`hello`命令 ``` php think hello ``` 輸出 ``` Hello thinkphp! ``` 添加命令參數 ``` php think hello liuchen ``` 輸出 ``` Hello liuchen! ``` 添加`city`選項 ``` php think hello liuchen --city shanghai ``` 輸出 ``` Hello thinkphp! From shanghai ``` > 注意看參數和選項的調用區別
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看