2015-05-22 12:36:26 -04:00
|
|
|
<?php
|
2015-06-16 11:11:35 -04:00
|
|
|
/**
|
2015-11-16 11:40:01 -05:00
|
|
|
* Hummingbird Anime Client
|
|
|
|
*
|
|
|
|
* An API client for Hummingbird to manage anime and manga watch lists
|
|
|
|
*
|
2016-08-30 10:57:41 -04:00
|
|
|
* PHP version 5.6
|
|
|
|
*
|
2015-11-16 11:40:01 -05:00
|
|
|
* @package HummingbirdAnimeClient
|
2016-08-30 10:57:41 -04:00
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2015 - 2016 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @version 3.1
|
2015-11-16 11:40:01 -05:00
|
|
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
2015-06-16 11:11:35 -04:00
|
|
|
*/
|
2016-02-10 17:30:45 -05:00
|
|
|
use Aviat\AnimeClient\AnimeClient;
|
2015-10-09 14:34:55 -04:00
|
|
|
use Whoops\Handler\PrettyPageHandler;
|
|
|
|
|
2015-06-25 17:00:29 -04:00
|
|
|
// Work around the silly timezone error
|
|
|
|
$timezone = ini_get('date.timezone');
|
|
|
|
if ($timezone === '' || $timezone === FALSE)
|
|
|
|
{
|
|
|
|
ini_set('date.timezone', 'GMT');
|
|
|
|
}
|
2015-06-11 16:44:52 -04:00
|
|
|
|
2015-09-14 10:54:50 -04:00
|
|
|
/**
|
|
|
|
* Joins paths together. Variadic to take an
|
|
|
|
* arbitrary number of arguments
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function _dir()
|
|
|
|
{
|
|
|
|
return implode(DIRECTORY_SEPARATOR, func_get_args());
|
|
|
|
}
|
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
// Define base directories
|
|
|
|
$APP_DIR = _dir(__DIR__, 'app');
|
|
|
|
$CONF_DIR = _dir($APP_DIR, 'config');
|
|
|
|
|
2016-08-29 16:36:13 -04:00
|
|
|
// Load composer autoloader
|
2016-01-06 15:44:40 -05:00
|
|
|
require _dir(__DIR__, '/vendor/autoload.php');
|
2015-10-09 14:34:55 -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
|
2016-02-10 17:30:45 -05:00
|
|
|
//$jsonHandler = new JsonResponseHandler();
|
|
|
|
//$whoops->pushHandler($jsonHandler);
|
2015-10-09 14:34:55 -04:00
|
|
|
|
2015-10-09 22:29:59 -04:00
|
|
|
// Register as the error handler
|
|
|
|
$whoops->register();
|
2015-10-09 14:34:55 -04:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Dependency Injection setup
|
|
|
|
// -----------------------------------------------------------------------------
|
2016-01-06 15:44:40 -05:00
|
|
|
require _dir($CONF_DIR, 'base_config.php'); // $base_config
|
|
|
|
$di = require _dir($APP_DIR, 'bootstrap.php');
|
|
|
|
|
2016-02-10 17:30:45 -05:00
|
|
|
$config = AnimeClient::load_toml($CONF_DIR);
|
|
|
|
$config_array = array_merge($base_config, $config);
|
|
|
|
|
|
|
|
$container = $di($config_array);
|
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
// Unset 'constants'
|
|
|
|
unset($APP_DIR);
|
|
|
|
unset($CONF_DIR);
|
|
|
|
|
2015-10-09 14:34:55 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Dispatch to the current route
|
|
|
|
// -----------------------------------------------------------------------------
|
2015-11-13 16:31:01 -05:00
|
|
|
$container->get('dispatcher')->__invoke();
|
2015-05-22 12:36:26 -04:00
|
|
|
|
|
|
|
// End of index.php
|