think\Console::init PHP 메소드

init() 공개 정적인 메소드

public static init ( $run = true )
    public static function init($run = true)
    {
        static $console;
        if (!$console) {
            // 实例化console
            $console = new self('Think Console', '0.1');
            // 读取指令集
            if (is_file(CONF_PATH . 'command' . EXT)) {
                $commands = (include CONF_PATH . 'command' . EXT);
                if (is_array($commands)) {
                    foreach ($commands as $command) {
                        if (class_exists($command) && is_subclass_of($command, "\\think\\console\\Command")) {
                            // 注册指令
                            $console->add(new $command());
                        }
                    }
                }
            }
        }
        if ($run) {
            // 运行
            return $console->run();
        } else {
            return $console;
        }
    }