From e2473598addd83e4973cd7fb8258d3706d0ebac8 Mon Sep 17 00:00:00 2001 From: rootcoma Date: Thu, 5 Dec 2013 15:52:04 -0800 Subject: [PATCH] Adding app.php --- php/app.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 php/app.php diff --git a/php/app.php b/php/app.php new file mode 100644 index 0000000..a2e8c17 --- /dev/null +++ b/php/app.php @@ -0,0 +1,42 @@ +$config['baseFolder'] . $config['baseRoute'], "routes"=>$routes); + +// Create the container +$container = new Bootstrap($config, $routeInfo); + + +// Start the application based on the route +// TODO: Should this be in the Bootstrap? +$currentRoute = $container->router->matchCurrentRequest(); +if(!$currentRoute) { + $container->render404(); +} + +$params = $currentRoute->getParameters(); +$target = $currentRoute->getTarget(); + +$parts = explode(':', $target); +if(count($parts) < 2) { + // configuration error + throw new Exception("Route is not properly configured."); +} + +$controllerName = $parts[0]; +$action = $parts[1]; + +$className = $controllerName . 'Controller'; +$actionName = $action . 'Action'; +$controller = new $className($container); +$controller->$actionName($params);