set_model_directory(HaloMVC\Config::option('models_dir')); $cfg->set_connections(array( 'development' => 'mysql://root@localhost/todolist', 'staging' => 'mysql://******:******@******/******', 'production' => 'mysql://******:******@******/******' )); $cfg->set_default_connection('development'); if ($log!==false) { $cfg->set_logger($log); $cfg->set_logging(true); } }); ///////////////////////////// // // init Twig Templating Engine // ///////////////////////////// require_once HaloMVC\Config::option('includes_dir') . '/Twig/Autoloader.php'; Twig_Autoloader::register(); ///////////////////////////// // // init Dispatcher and build routes // ///////////////////////////// $dispatcher = new HaloMVC\Dispatcher; $dispatcher->setSuffix('Controller'); $dispatcher->setClassPath(HaloMVC\Config::option('controllers_dir').'/'); $dispatcher->buildRotues(); $url = urldecode($_SERVER['REQUEST_URI']); $router = HaloMVC\Router::getInstance(); try { $found_route = $router->findRoute($url); $dispatcher->dispatch( $found_route ); } catch ( HaloMVC\RouteNotFoundException $e ) { $default_route = $router->findRoute('/'); $dispatcher->dispatch( $default_route ); //throw new HaloMVC\RouteNotFoundException('Route ' . $url . ' not found.'); } catch ( HaloMVC\badClassNameException $e ) { HaloMVC\vPageError::show('400', $url); } catch ( HaloMVC\classFileNotFoundException $e ) { throw new HaloMVC\classFileNotFoundException('classFile for Route ' . $url . ' not found.'); } catch ( HaloMVC\classNameNotFoundException $e ) { HaloMVC\PageError::show('500', $url); } catch ( HaloMVC\classMethodNotFoundException $e ) { HaloMVC\PageError::show('500', $url); } catch ( HaloMVC\classNotSpecifiedException $e ) { HaloMVC\PageError::show('500', $url); } catch ( HaloMVC\methodNotSpecifiedException $e ) { HaloMVC\PageError::show('500', $url); } ?>