public function bootstrap() { $this->constant(); //加载服务配置项 $servers = (require __DIR__ . '/service.php'); $config = (require ROOT_PATH . '/system/config/service.php'); $servers['providers'] = array_merge($config['providers'], $servers['providers']); $servers['facades'] = array_merge($config['facades'], $servers['facades']); $this->servers = $servers; //自动加载系统服务 Loader::register([$this, 'autoload']); //绑定核心服务提供者 $this->bindServiceProvider(); //添加初始实例 $this->instance('App', $this); //设置外观类APP属性 ServiceFacade::setFacadeApplication($this); //启动服务 $this->boot(); //定义错误/异常处理 Error::bootstrap(); //命令行模式 IS_CLI and die(Cli::bootstrap()); //导入类库别名 Loader::addMap(c('app.alias')); //自动加载文件 Loader::autoloadFile(); //开启会话 Session::start(); //执行全局中间件 Middleware::globals(); //解析路由 Route::dispatch(); }
function cli() { $argv[] = 'hd'; foreach (func_get_args() as $v) { $argv[] = $v; } $_SERVER['argv'] = $argv; Cli::bootstrap(); }