index.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $whoops = new \Whoops\Run;
  27. $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  28. $whoops->register();
  29. // Define base directories
  30. $APP_DIR = _dir(__DIR__, 'app');
  31. $APPCONF_DIR = _dir($APP_DIR, 'appConf');
  32. $CONF_DIR = _dir($APP_DIR, 'config');
  33. // -----------------------------------------------------------------------------
  34. // Dependency Injection setup
  35. // -----------------------------------------------------------------------------
  36. $base_config = require $APPCONF_DIR . '/base_config.php';
  37. $di = require $APP_DIR . '/bootstrap.php';
  38. $config = loadToml($CONF_DIR);
  39. $config_array = array_merge($base_config, $config);
  40. $container = $di($config_array);
  41. // Unset 'constants'
  42. unset($APP_DIR, $APPCONF_DIR);
  43. // -----------------------------------------------------------------------------
  44. // Dispatch to the current route
  45. // -----------------------------------------------------------------------------
  46. $container->get('dispatcher')();