model; $ctrlClass = '\\app\\' . $model . '\\' . "controller" . '\\'. $route->ctrl; $action = $route->action; $ctrl = new $ctrlClass(); $ctrl->$action(); } public static function init() { Config::load(); } } // /** // * 执行应用程序 // * @access public // * @param Request $request Request对象 // * @return Response // * @throws Exception // */ // public static function run(Request $request = null) // { // is_null($request) && $request = Request::instance(); // try { // $config = self::initCommon(); // if (defined('BIND_MODULE')) { // // 模块/控制器绑定 // BIND_MODULE && Route::bind(BIND_MODULE); // } elseif ($config['auto_bind_module']) { // // 入口自动绑定 // $name = pathinfo($request->baseFile(), PATHINFO_FILENAME); // if ($name && 'index' != $name && is_dir(APP_PATH . $name)) { // Route::bind($name); // } // } // $request->filter($config['default_filter']); // // 默认语言 // Lang::range($config['default_lang']); // if ($config['lang_switch_on']) { // // 开启多语言机制 检测当前语言 // Lang::detect(); // } // $request->langset(Lang::range()); // // 加载系统语言包 // Lang::load([ // THINK_PATH . 'lang' . DS . $request->langset() . EXT, // APP_PATH . 'lang' . DS . $request->langset() . EXT, // ]); // // 获取应用调度信息 // $dispatch = self::$dispatch; // if (empty($dispatch)) { // // 进行URL路由检测 // $dispatch = self::routeCheck($request, $config); // } // // 记录当前调度信息 // $request->dispatch($dispatch); // // 记录路由和请求信息 // if (self::$debug) { // Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info'); // Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info'); // Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info'); // } // // 监听app_begin // Hook::listen('app_begin', $dispatch); // // 请求缓存检查 // $request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']); // $data = self::exec($dispatch, $config); // } catch (HttpResponseException $exception) { // $data = $exception->getResponse(); // } // // 清空类的实例化 // Loader::clearInstance(); // // 输出数据到客户端 // if ($data instanceof Response) { // $response = $data; // } elseif (!is_null($data)) { // // 默认自动识别响应输出类型 // $isAjax = $request->isAjax(); // $type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type'); // $response = Response::create($data, $type); // } else { // $response = Response::create(); // } // // 监听app_end // Hook::listen('app_end', $response); // return $response; // } // $a(); // 调用指定方法 // } // }