2015-06-29 09:46:49 -04:00
|
|
|
<?php
|
2015-09-14 10:54:50 -04:00
|
|
|
/**
|
|
|
|
* Bootstrap / Dependency Injection
|
|
|
|
*/
|
2015-06-29 09:46:49 -04:00
|
|
|
|
2015-09-14 19:54:34 -04:00
|
|
|
namespace Aviat\AnimeClient;
|
2015-06-29 09:46:49 -04:00
|
|
|
|
|
|
|
use \Whoops\Handler\PrettyPageHandler;
|
|
|
|
use \Whoops\Handler\JsonResponseHandler;
|
|
|
|
use \Aura\Web\WebFactory;
|
|
|
|
use \Aura\Router\RouterFactory;
|
2015-09-14 10:54:50 -04:00
|
|
|
use \Aura\Di\Container as DiContainer;
|
|
|
|
use \Aura\Di\Factory as DiFactory;
|
|
|
|
|
|
|
|
require _dir(SRC_DIR, '/functions.php');
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Setup DI container
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
$container = new Base\Container();
|
2015-06-29 09:46:49 -04:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Setup error handling
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
$whoops = new \Whoops\Run();
|
|
|
|
|
|
|
|
// Set up default handler for general errors
|
|
|
|
$defaultHandler = new PrettyPageHandler();
|
|
|
|
$whoops->pushHandler($defaultHandler);
|
|
|
|
|
|
|
|
// Set up json handler for ajax errors
|
|
|
|
$jsonHandler = new JsonResponseHandler();
|
|
|
|
$jsonHandler->onlyForAjaxRequests(true);
|
|
|
|
$whoops->pushHandler($jsonHandler);
|
|
|
|
|
|
|
|
$whoops->register();
|
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
$container->set('error-handler', $defaultHandler);
|
|
|
|
|
2015-06-29 09:46:49 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Injected Objects
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Create Config Object
|
2015-09-14 10:54:50 -04:00
|
|
|
$config = new Base\Config();
|
|
|
|
$container->set('config', $config);
|
2015-06-29 09:46:49 -04:00
|
|
|
|
|
|
|
// Create Aura Router Object
|
|
|
|
$router_factory = new RouterFactory();
|
|
|
|
$aura_router = $router_factory->newInstance();
|
2015-09-14 10:54:50 -04:00
|
|
|
$container->set('aura-router', $aura_router);
|
2015-06-29 09:46:49 -04:00
|
|
|
|
|
|
|
// Create Request/Response Objects
|
|
|
|
$web_factory = new WebFactory([
|
|
|
|
'_GET' => $_GET,
|
|
|
|
'_POST' => $_POST,
|
|
|
|
'_COOKIE' => $_COOKIE,
|
|
|
|
'_SERVER' => $_SERVER,
|
|
|
|
'_FILES' => $_FILES
|
|
|
|
]);
|
2015-09-14 10:54:50 -04:00
|
|
|
$container->set('request', $web_factory->newRequest());
|
|
|
|
$container->set('response', $web_factory->newResponse());
|
2015-06-29 09:46:49 -04:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Router
|
|
|
|
// -----------------------------------------------------------------------------
|
2015-09-14 15:49:20 -04:00
|
|
|
$container->set('url-generator', new Base\UrlGenerator($container));
|
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
$router = new Base\Router($container);
|
2015-06-29 09:46:49 -04:00
|
|
|
$router->dispatch();
|
|
|
|
|
|
|
|
// End of bootstrap.php
|