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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 創建命令 命令就是一個命令行程序,`Command` 類似于 HTTP 應用的 `Controller` 控制器,負責業務邏輯,不同的是命令行程序通常是處理復雜的數據處理邏輯,相比簡單的 `CRUD` 操作要復雜很多。 ## 一個簡單的命令 首先在配置文件 `manifest.php` 的 `commands` 或者 `commandPath` 中增加命令。 - commands ~~~ // 命令 'commands' => [ 'he' => [ \App\Console\Commands\HelloCommand::class, 'description' => "\tEcho demo", 'options' => [ [['n', 'name'], 'description' => 'Your name'], ['say', 'description' => "\tSay ..."], ], ], ], ~~~ - commandPath 在 `commandPath` 指定的目錄中任意創建一個文件,內容如下: ~~~ // 命令 return [ 'he' => [ \App\Console\Commands\HelloCommand::class, 'description' => "\tEcho demo", 'options' => [ [['n', 'name'], 'description' => 'Your name'], ['say', 'description' => "\tSay ..."], ], ], ]; ~~~ 詳解命令規則: - 命令名稱: `he` - 命令類的類名:`\App\Console\Commands\HelloCommand::class` - `description` 命令的描述,命令 `-h` 時顯示,(可不定義) - `options` 命令的參數,參數 `-h` 時顯示,(可不定義) - `['n', 'name']`、`'say'` 命令參數的名稱,可為字符或數組,**所有參數都必須在這里注冊方可使用**。 - `options.description` 參數的描述,參數 `COMMAND -h` 時顯示,(可不定義) 當在 [mix-phar](https://github.com/mix-php/mix-phar) 中開發時還可以進行單命令配置,使整個 phar 文件為一個命令,配置方式如下: ~~~ // 命令 'commands' => [ \App\Console\Commands\HelloCommand::class, 'description' => "\tEcho demo", 'options' => [ [['n', 'name'], 'description' => 'Your name'], ['say', 'description' => "\tSay ..."], ], ], ~~~ 創建命令類,代碼如下: ~~~ <?php namespace App\Console\Commands; use Mix\Console\CommandLine\Flag; /** * Class HelloCommand * @package App\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 App\Console\Commands; ~~~ 因為根命名空間 `App` 在 `composer.json` 內定義的路徑為 : ~~~ "psr-4": { "App\\": "app/" }, ~~~ 所以控制器的完整路徑為: ~~~ app/Console/Commands/HelloCommand.php ~~~ ## 命令行執行 執行上面寫的命令。 ~~~shell // 不帶參數 php bin/mix.php he // 帶參數 php bin/mix.php he -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>

                              哎呀哎呀视频在线观看