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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 創建命令 命令就是一個命令行程序,`Command` 類似于 HTTP 應用的 `Controller` 控制器,負責業務邏輯,不同的是命令行程序通常是處理復雜的數據處理邏輯,相比簡單的 `CRUD` 操作要復雜很多。 | 類 | | --- | | mix\console\Command | >[info] 初始代碼中命令行應用的命令在 commands 目錄。 ## 一個簡單的命令 首先在配置文件中增加命令。 ~~~ // 命令 'commands' => [ 'clear exec' => ['Clear', 'Exec'], ], ~~~ 詳解命令規則: - 命令:`clear exec` - 命令類的類名,不包括 Command 后綴:`Clear` - 命令類的方法名,不包括 action 前綴:`Exec` 創建命令類,代碼如下: ~~~ <?php namespace apps\console\commands; use mix\console\Command; use mix\console\ExitCode; use mix\facades\Output; /** * Clear 命令 * @author 劉健 <coder.liu@qq.com> */ class ClearCommand extends Command { // 執行任務 public function actionExec() { // 響應 Output::writeln('SUCCESS'); // 返回退出碼 return ExitCode::OK; } } ~~~ ## 命名空間與文件位置的關系 控制器定義的命名空間為: ~~~ namespace apps\console\commands; ~~~ 因為根命名空間 `apps` 在 `composer.json` 內定義的路徑為 : ~~~ "apps\\": "apps/" ~~~ 所以控制器的完整路徑為: ~~~shell apps/console/commands/ClearCommand.php ~~~ ## 命令行執行 執行上面寫的命令。 ~~~shell mix-console clear exec ~~~ ## 如何使用命令選項 修改上面的命令類,代碼如下: ~~~ <?php namespace apps\console\commands; use mix\console\Command; use mix\console\ExitCode; use mix\facades\Input; use mix\facades\Output; use mix\helpers\ProcessHelper; /** * Clear 命令 * @author 劉健 <coder.liu@qq.com> */ class ClearCommand extends Command { // 是否后臺運行 public $daemon = false; // 選項配置 public function options() { return ['daemon']; } // 選項別名配置 public function optionAliases() { return ['d' => 'daemon']; } // 執行任務 public function actionExec() { // 蛻變為守護進程 if ($this->daemon) { ProcessHelper::daemon(); } // 修改進程名稱 Process::setName('mix-crontab: ' . Input::getCommandName()); // 響應 Output::writeln('SUCCESS'); // 返回退出碼 return ExitCode::OK; } } ~~~ - options 方法定義了一個 daemon 選項,所以命令只會接收 `--daemon` 選項。 - optionAliases 方法給 daemon 選項定義了一個別名,所以 `-d` 等效于 `--daemon` 。 執行上面寫的命令,并傳入選項: ~~~shell mix-console clear exec -d ~~~
                  <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>

                              哎呀哎呀视频在线观看