Improvements based on import test.
[rock.divinelegy.git] / public_html / index.php
1 <?php
2
3 require_once('../vendor/autoload.php');
4
5 $config = require('../config/app.php');
6
7 // Allow these origins to do cross domain JS.
8 header("Access-Control-Allow-Origin: " . $config['allow-origin']);
9
10 // Nice exceptions
11 if($config['mode'] == 'production') set_exception_handler(array('\Services\StatusReporter', 'exception'));
12
13 // Everything time related should be UTC+0 based
14 date_default_timezone_set('UTC');
15
16 // Set up the DI container
17 $containerBuilder = new DI\ContainerBuilder();
18 $containerBuilder->addDefinitions('../config/DI.php');
19 $containerBuilder->useAutowiring(true);
20
21 $container = $containerBuilder->build();
22
23 /* @var $router Services\Routing\IRouter */
24 $router = $container->get('Services\Routing\IRouter');
25
26 $controllerName= $router->getControllerName();
27 $controllerAction = $router->getActionName();
28 $controllerActionArgs = $router->getActionArgs();
29
30 $controller = $container->get('Controllers\\' . ucfirst($controllerName) . 'Controller' );
31
32 // Last thing to do, call the action on the specified controller.
33 call_user_func_array(array($controller, $controllerAction . 'Action'), $controllerActionArgs);