API client for Kitsu.io, with optional Anime collection, and optional Anilist syncing.
anime
manga
kitsu
anilist
single-user

index.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.1
  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.1
  14. * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
  15. */
  16. namespace Aviat\AnimeClient;
  17. use Aviat\AnimeClient\Types\Config as ConfigType;
  18. use function Aviat\Ion\_dir;
  19. setlocale(LC_CTYPE, 'en_US');
  20. // Work around the silly timezone error
  21. $timezone = ini_get('date.timezone');
  22. if ($timezone === '' || $timezone === FALSE)
  23. {
  24. ini_set('date.timezone', 'GMT');
  25. }
  26. // Load composer autoloader
  27. require_once __DIR__ . '/vendor/autoload.php';
  28. // if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development')
  29. {
  30. $whoops = new \Whoops\Run;
  31. $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  32. $whoops->register();
  33. }
  34. // Define base directories
  35. $APP_DIR = _dir(__DIR__, 'app');
  36. $APPCONF_DIR = _dir($APP_DIR, 'appConf');
  37. $CONF_DIR = _dir($APP_DIR, 'config');
  38. // -----------------------------------------------------------------------------
  39. // Dependency Injection setup
  40. // -----------------------------------------------------------------------------
  41. $baseConfig = require "{$APPCONF_DIR}/base_config.php";
  42. $di = require "{$APP_DIR}/bootstrap.php";
  43. $config = loadToml($CONF_DIR);
  44. $overrideFile = "{$CONF_DIR}/admin-override.toml";
  45. $overrideConfig = file_exists($overrideFile)
  46. ? loadTomlFile($overrideFile)
  47. : [];
  48. $configArray = array_replace_recursive($baseConfig, $config, $overrideConfig);
  49. $checkedConfig = (new ConfigType($configArray))->toArray();
  50. $container = $di($checkedConfig);
  51. // Unset 'constants'
  52. unset($APP_DIR, $CONF_DIR, $APPCONF_DIR);
  53. // -----------------------------------------------------------------------------
  54. // Dispatch to the current route
  55. // -----------------------------------------------------------------------------
  56. $container->get('dispatcher')();