Ejemplo n.º 1
0
    }
    //定义cache server
    $cacheConf = config::get('cache');
    //读取配置文件,注意配置文件中的格式
    foreach ($cacheConf as $alias => $conf) {
        cache::addServer($alias, $conf);
    }
    //============================ 开始路由和执行controller 层中 ============================
    //检测并获取到uri,当然也可以自己指定
    $uri = dispatcher::detectUri();
    //$uri = '/';
    /*
         * 可以自己随意接受一些参数然后设置 uri 进行转发
          $controller = request::get('c');
          $action = request::get('a');
          $uri = '/'.$action.'/'.$action;
    */
    // 开始路由和执行
    dispatcher::instance()->setPathDeep(dispatcher::path_deep2)->setDefaultModule('index')->setDefaultController('index')->setDefaultAction('index')->setUri($uri)->dispatch()->run();
    //开始执行上一步路由后的 controller 和 action
    //dispatcher::instance()->setControllerName('index')->setActionName('index')->run();
    //============================ 几种常见的异常 ============================
    //} catch (TException_404 $e) {               //当 controller 和 action 不存在时,捕获到的 404 错误。daemon 状态下应该没有
    //    tools_exceptionhandler::topDeal404($e);
} catch (ReflectionException $e) {
    //一般来说,这种情况不太可能发生
    tools_exceptionhandler::topDeal404($e);
} catch (Exception $e) {
    //做个最后的兼容
    tools_exceptionhandler::topDeal($e);
}
Ejemplo n.º 2
0
 public function forward($path)
 {
     dispatcher::instance()->setUri($path)->dispatch()->run();
 }