Exemple #1
0
 function handleRequest()
 {
     $config = ConfigurationManager::instance();
     $uri = $_SERVER['REQUEST_URI'];
     if (list($route, $matches) = $config->routes->match($uri)) {
         if (!array_key_exists('controller', $route->args)) {
             echo 'No "controller" attribute specified for route.';
             print_r($route);
             exit;
         }
         if (!array_key_exists('action', $route->args)) {
             echo 'No "action" attribute specified for route.';
             print_r($route);
             exit;
         }
         $rd = new RouteDispatcher();
         $rd->dispatch($route, $matches);
     } else {
         header("HTTP/1.0 404 Not Found");
         header("Status: 404 Not Found");
         die('No match found');
     }
 }
Exemple #2
0
 public function execute(App $app)
 {
     //开始路由,query参数需要有url和param两个变量。方便路由选择
     $dispatcher = new RouteDispatcher();
     $dispatcher->run();
 }