/** * Main dispatcher * * @param string * Path to the specific application relative to the foo-mvc app dir base */ public static function dispatch($app_path = NULL) { $app_path = dirname(__FILE__) . '/apps' . ($app_path ? '/' . $app_path : ''); self::$dir_controllers = $app_path . '/controllers/'; self::$dir_models = $app_path . '/models/'; self::$dir_views = $app_path . '/views/'; if (!self::$route_file) { self::$route_file = $app_path . '/routes.ini'; } $router = new Router(self::$route_file); self::$current_url = parse_url($_SERVER['REQUEST_URI']); if (!($controller_name = $router->url2controller(self::$current_url['path']))) { throw new FooMVCDispatchException("No controller specified for this route."); } $controller_name = str_replace('.', '_', $controller_name); self::forward($controller_name); self::runView(); }