<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之旅 廣告
                [TOC] * * * * * ## 1 控制臺源代碼 (think/library/think/Console.php)方法列表 ~~~ private $name; private $version; private $commands = []; private $wantHelps = false; private $runningCommand; private $catchExceptions = true; private $autoExit = true; private $definition; private $helperSet; private $terminalDimensions; private $defaultCommand; ~~~ `public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN'){}` `public function run(){}` `public function doRun(Input $input, Output $output){}` `public function setHelperSet(HelperSet $helperSet)` `public function getHelperSet()` `public function setDefinition(InputDefinition $definition){}` `public function getDefinition(){}` `public function getHelp(){}` `public function setCatchExceptions($boolean){}` `public function setAutoExit($boolean){}` `public function getName(){}` `public function setName($name){}` `public function getVersion(){}` `public function setVersion($version){}` `public function getLongVersion(){}` `public function register($name){}` `public function addCommands(array $commands){}` `public function get($name){}` `public function has($name){}` `public function getNamespaces(){}` `public function findNamespace($namespace){}` `public function find($name){}` `public function all($namespace = null){}` `public static function getAbbreviations($names){}` `public function renderException(\Exception $e, Stream $output){}` `protected function getTerminalWidth(){}` `protected function getTerminalHeight(){}` `public function getTerminalDimensions(){}` `public function setTerminalDimensions($width, $height){}` `protected function configureIO(Input $input, Output $output){}` `protected function doRunCommand(Command $command, Input $input, Output $output){}` `protected function getCommandName(Input $input){}` `protected function getDefaultInputDefinition(){}` `protected function getDefaultCommands(){}` `protected function getDefaultCommands(){}` `protected function getDefaultHelperSet(){}` `private function getSttyColumns(){}` `private function getConsoleMode(){}` `private function getAbbreviationSuggestions($abbrevs){}` `public function extractNamespace($name, $limit = null){}` `private function findAlternatives($name, $collection){}` `public function setDefaultCommand($commandName){}` `private function stringWidth($string){}` `private function splitStringByWidth($string, $width){}` `private function extractAllNamespaces($name){}` ## 2 文件分析 ### 1 成員變量 $name,$version:控制臺的名稱和版本號 $commands:指令集數組 $wantHelps:??? $runningCommand:當前運行指令 $catchException, autoExit:控制臺運行狀態控制 $defintion:輸入參數定義 $helperSet:助手集 $terminalDimensions:終端尺寸 $defaultCommand:默認運行指令 * * * * * ### 2 public方法(30個) `__construct()` 初始化控制臺 > $name:控制臺名稱 > $version:控制臺版本 * * * * * `run()` 從輸入獲取指令并執行 * * * * * `doRun()` 解析指令并運行 > $input:輸入接口 > $output:輸出接口 * * * * * `setHelperSet() getHelperSet()` 設置和獲取助手集 > $helperSet:助手集參數 * * * * * `setDefinition() getDefinition()` 設置和獲取輸入參數定義 > $definition:輸入參數定義 * * * * * `getHelp()` 獲取幫助信息 * * * * * `setCatchExceptions()` 是否捕獲異常 > $boolean: 設置控制臺參數$catchExceptions * * * * * `setAutoExit()` 是否自動退出 > $boolean: 設置控制臺參數$autoExit * * * * * `getName() setName() `獲取和設置控制臺名稱 > $name:控制臺名稱參數$name * * * * * `getVersion() setVersion()` 獲取和設置控制臺版本 > $version:控制臺版本參數$version * * * * * `getLongVersion()` 獲取完整版本的號 添加和獲取指令 * * * * * `register() addCommands() add() get() has() find() all() getAbbreviations()` > $name 指令名稱 * * * * * `getNamespaces() findNamespace()` 獲取命名空間信息 * * * * * `getTerminalDimensions() setTerminalDimensions()` 獲取和設置終端尺寸信息 * * * * * `renderException()` 輸出異常信息 * * * * * `extractNamespace()` 返回指令命名空間部分 * * * * * `setDefaultCommand()` 設置默認的指令 * * * * * ### 3 protected方法(9個) `getTerminalWidth() getTerminalHeight() ` 獲取終端寬度和高度 * * * * * `configureIO()` 配置輸入和輸出對象 * * * * * `doRunCommand()` 運行指令 * * * * * `getCommandName()` 獲取指令的基礎名稱 * * * * * `getDefaultInputDefinition()` 獲取默認輸入定義 * * * * * `getDefaultCommands()` 設置默認命令 * * * * * `getDefaultHelperSet()` 設置默認助手 * * * * * `getSttyColumns()` 獲取stty列數 ### 4 Private 私有方法(6個) `getConsoleMode()` 獲取終端模式 `getAbbreviationSuggestions()` 獲取可能的建議 `findAlternatives()` 查找可替代的建議 `stringWidth()` 字符串長度 `splitStringByWidth()` 字符串切割 `extractAllNamespaces()` 返回所有命名空間 ## 3 控制臺的使用 ### 3-1 添加命令配置 添加需要執行的命令類名 ~~~ application\command.php return ['think\console\command\Test']; ~~~ ### 3-2 命令執行實現 命令類的實現 繼承think\console\command類 實現 configure() execute()方法 ~~~ thinkphp\library\think\console\command\Test.php <?php namespace think\console\command; use think\console\Input; use think\console\Output; class Test extends Command { protected function configure() { $this->setName('test') ->setDescription('Command Test'); } protected function execute(Input $input, Output $output) { $output->writeln("TestCommand:"); } } ~~~ ### 3-3 控制臺入口測試 1 打開命令,進入框架根目錄(console文件所在目錄) ![](https://box.kancloud.cn/2016-03-28_56f8de1ba5a04.jpg) 2 輸入測試命令 php console test ![](https://box.kancloud.cn/2016-03-28_56f8de1bba43b.jpg) 3 輸出結果 ![](https://box.kancloud.cn/2016-03-28_56f8de1bcfe67.jpg) 4 在命令實現文件的execute()中添加相應功能即可 ## 4 總結 控制臺是tp5新的功能。 其接口是 Console.php文件, 9個成員變量 30個public方法 9個protected方法 6個private方法 實現在[D:(\concole\)控制臺](http://www.hmoore.net/zmwtp/tp5/120858)目錄
                  <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>

                              哎呀哎呀视频在线观看