Example #1
0
 public static function Run()
 {
     $found = false;
     $appRoutes = Route::$routes;
     # Sort the routes, so we make sure routes containing word boundaries matches before wildcards
     arsort($appRoutes);
     foreach ($appRoutes as $route) {
         if (preg_match($route['route'], $_SERVER['REQUEST_URI'], $matches)) {
             if ($_SERVER['REQUEST_METHOD'] != $route['request']) {
                 continue;
             }
             $found = true;
             self::$currentSlug = $route['slug'];
             Route::Dispatch($route['controller'], $route['method']);
             break;
         }
     }
     # If no route found in collection - Abort app and send user to 404 page
     if ($found === false) {
         App::Abort();
     }
 }