index.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php declare(strict_types=1);
  2. /**
  3. * Hummingbird Anime List Client
  4. *
  5. * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
  6. *
  7. * PHP version 7
  8. *
  9. * @package HummingbirdAnimeClient
  10. * @author Timothy J. Warren <tim@timshomepage.net>
  11. * @copyright 2015 - 2018 Timothy J. Warren
  12. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  13. * @version 4.0
  14. * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
  15. */
  16. namespace Aviat\AnimeClient;
  17. use function Aviat\Ion\_dir;
  18. // Work around the silly timezone error
  19. $timezone = ini_get('date.timezone');
  20. if ($timezone === '' || $timezone === FALSE)
  21. {
  22. ini_set('date.timezone', 'GMT');
  23. }
  24. // Load composer autoloader
  25. require_once __DIR__ . '/vendor/autoload.php';
  26. // if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
  27. {
  28. $whoops = new \Whoops\Run;
  29. $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  30. $whoops->register();
  31. }
  32. // Define base directories
  33. $APP_DIR = _dir(__DIR__, 'app');
  34. $APPCONF_DIR = _dir($APP_DIR, 'appConf');
  35. $CONF_DIR = _dir($APP_DIR, 'config');
  36. // -----------------------------------------------------------------------------
  37. // Dependency Injection setup
  38. // -----------------------------------------------------------------------------
  39. $base_config = require $APPCONF_DIR . '/base_config.php';
  40. $di = require $APP_DIR . '/bootstrap.php';
  41. $config = loadToml($CONF_DIR);
  42. $config_array = array_merge($base_config, $config);
  43. $container = $di($config_array);
  44. // Unset 'constants'
  45. unset($APP_DIR, $APPCONF_DIR);
  46. // -----------------------------------------------------------------------------
  47. // Dispatch to the current route
  48. // -----------------------------------------------------------------------------
  49. $container->get('dispatcher')();