Do you wish to register an account?
API client for Kitsu.io, with optional Anime collection, and optional Anilist syncing.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

84 lines
2.3 KiB

  1. <?php declare(strict_types=1);
  2. /**
  3. * Hummingbird Anime List Client
  4. *
  5. * An API client for Kitsu to manage anime and manga watch lists
  6. *
  7. * PHP version 7.4
  8. *
  9. * @package HummingbirdAnimeClient
  10. * @author Timothy J. Warren <tim@timshomepage.net>
  11. * @copyright 2015 - 2020 Timothy J. Warren
  12. * @license http://www.opensource.org/licenses/mit-license.html MIT License
  13. * @version 5
  14. * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
  15. */
  16. namespace Aviat\AnimeClient;
  17. use Aviat\AnimeClient\Types\Config as ConfigType;
  18. use Whoops\Handler\PrettyPageHandler;
  19. use Whoops\Run;
  20. use function Aviat\Ion\_dir;
  21. setlocale(LC_CTYPE, 'en_US');
  22. // Load composer autoloader
  23. require_once __DIR__ . '/vendor/autoload.php';
  24. if (file_exists('.is-dev'))
  25. {
  26. $whoops = new Run;
  27. $whoops->pushHandler(new PrettyPageHandler);
  28. $whoops->register();
  29. }
  30. // Define base directories
  31. $APP_DIR = _dir(__DIR__, 'app');
  32. $APPCONF_DIR = _dir($APP_DIR, 'appConf');
  33. $CONF_DIR = _dir($APP_DIR, 'config');
  34. // -----------------------------------------------------------------------------
  35. // Dependency Injection setup
  36. // -----------------------------------------------------------------------------
  37. $baseConfig = require "{$APPCONF_DIR}/base_config.php";
  38. $di = require "{$APP_DIR}/bootstrap.php";
  39. $config = loadToml($CONF_DIR);
  40. $overrideFile = "{$CONF_DIR}/admin-override.toml";
  41. $overrideConfig = file_exists($overrideFile)
  42. ? loadTomlFile($overrideFile)
  43. : [];
  44. $configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
  45. $checkedConfig = ConfigType::check($configArray);
  46. // Set the timezone for date display
  47. // First look in app config, then PHP config, and at last
  48. // resort, just set to UTC.
  49. $timezone = ini_get('date.timezone');
  50. if (array_key_exists('timezone', $checkedConfig) && ! empty($checkedConfig['timezone']))
  51. {
  52. date_default_timezone_set($checkedConfig['timezone']);
  53. }
  54. else if ($timezone !== '')
  55. {
  56. date_default_timezone_set($timezone);
  57. }
  58. else
  59. {
  60. date_default_timezone_set('UTC');
  61. }
  62. $container = $di($checkedConfig);
  63. // Unset 'constants'
  64. unset($APP_DIR, $CONF_DIR, $APPCONF_DIR);
  65. // -----------------------------------------------------------------------------
  66. // Dispatch to the current route
  67. // -----------------------------------------------------------------------------
  68. $container->get('dispatcher')();