be2b6953e2ec4c3aea768ec54cd21ec759520c78
[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 header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
10
11 // Nice exceptions
12 if($config['mode'] == 'production')
13 {
14 ini_set('display_errors', 0);
15 set_exception_handler(array('\Services\StatusReporter', 'exception'));
16 } else {
17 ini_set('display_errors', 1);
18 error_reporting(E_ALL);
19 }
20
21 // Everything time related should be UTC+0 based
22 date_default_timezone_set('UTC');
23
24 // Set up the DI container
25 $containerBuilder = new DI\ContainerBuilder();
26 $containerBuilder->addDefinitions('../config/DI.php');
27 $containerBuilder->useAutowiring(true);
28
29 $container = $containerBuilder->build();
30
31 /* @var $router Services\Routing\IRouter */
32 $router = $container->get('Services\Routing\IRouter');
33
34 $controllerName= $router->getControllerName();
35 $controllerAction = $router->getActionName();
36 $controllerActionArgs = $router->getActionArgs();
37
38 $controller = $container->get('Controllers\\' . ucfirst($controllerName) . 'Controller' );
39
40 // Last thing to do, call the action on the specified controller.
41 call_user_func_array(array($controller, $controllerAction . 'Action'), $controllerActionArgs);