<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## 創建命令 命令就是一個命令行程序,`Command` 類似于 HTTP 應用的 `Controller` 控制器,負責業務邏輯,不同的是命令行程序通常是處理復雜的數據處理邏輯,相比簡單的 `CRUD` 操作要復雜很多。 >[info] 初始代碼中命令行應用的命令在 `src/Commands` 目錄。 ## 一個簡單的命令 首先在配置文件 `config/main.php` 中增加命令。 ~~~ // 命令 'commands' => [ 'hl' => [ 'Hello', 'description' => "Demo.", 'options' => [ [['n', 'name'], 'description' => 'Your name.'], ['say', 'description' => "\tSay ..."], ], ], ], ~~~ 詳解命令規則: - 命令名稱: `hl` - 命令類的類名,不包括 Command 后綴:`Hello` - `description` 命令的描述,命令 `-h` 時顯示,(可不定義) - `options` 命令的參數,參數 `-h` 時顯示,(可不定義) - `['n', 'name']`、`'say'` 命令參數的名稱,可為字符或數組,**所有參數都必須在這里注冊方可使用**。 - `options.description` 參數的描述,參數 `COMMAND -h` 時顯示,(可不定義) 創建命令類,代碼如下: ~~~ <?php namespace Console\Commands; use Mix\Console\CommandLine\Flag; /** * Class HelloCommand * @package Console\Commands * @author liu,jian <coder.keda@gmail.com> */ class HelloCommand { /** * 主函數 */ public function main() { $name = Flag::string(['n', 'name'], 'Xiao Ming'); $say = Flag::string('say', 'Hello, World!'); println("{$name}: {$say}"); } } ~~~ ## 命名空間與文件位置的關系 控制器定義的命名空間為: ~~~ namespace Console\Commands; ~~~ 因為根命名空間 `http://applications/console/src/` 在 `composer.json` 內定義的路徑為 : ~~~ "psr-4": { "Console\\": "applications/console/src/", }, ~~~ 所以控制器的完整路徑為: ~~~ applications/console/src/Commands/HelloCommand.php ~~~ ## 命令行執行 執行上面寫的命令。 ~~~shell // 不帶參數 php mix-console hl // 帶參數 php mix-console hl -n "Xiao Hua" --say=Hi ~~~
                  <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>

                              哎呀哎呀视频在线观看