Example #1
0
 /**
  * 启动程序
  * @return [type] [description]
  */
 public function start()
 {
     $this->init();
     //数据库初使化
     DB::init();
     //路由初使化
     Router::init();
     //TODO:: 还需要支持自定义的路由
     if (file_exists(APP_PATH . 'config/Router.php')) {
     }
     //调用控制器
     $controllerFile = APP_PATH . MODULE . 'controller/' . CONTROLLER . CLASS_EXT;
     if (file_exists($controllerFile)) {
         include_once $controllerFile;
         $controller = MODULE ? MODULE : "Controller" . '\\' . CONTROLLER;
         $action = ACTION;
         $obj = new $controller();
         if (method_exists($obj, $action)) {
             $obj->{$action}();
         } else {
             throw new \Exception("非法操作: " . ACTION);
         }
     } else {
         throw new \Exception("无法加载控制器: " . CONTROLLER);
     }
 }