plugins-bootstrap.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use Grav\Common\Grav;
  3. use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
  4. \define('GRAV_CLI', true);
  5. \define('GRAV_REQUEST_TIME', microtime(true));
  6. \define('GRAV_USER_INSTANCE', 'FLEX');
  7. $autoload = require __DIR__ . '/../../vendor/autoload.php';
  8. if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
  9. exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
  10. }
  11. if (!ini_get('date.timezone')) {
  12. date_default_timezone_set('UTC');
  13. }
  14. if (!file_exists(GRAV_ROOT . '/index.php')) {
  15. exit('FATAL: Must be run from ROOT directory of Grav!');
  16. }
  17. $grav = Grav::instance(array('loader' => $autoload));
  18. $grav->setup('tests');
  19. $grav['config']->init();
  20. // Find all plugins in Grav installation and autoload their classes.
  21. /** @var UniformResourceLocator $locator */
  22. $locator = Grav::instance()['locator'];
  23. $iterator = $locator->getIterator('plugins://');
  24. foreach($iterator as $directory) {
  25. if (!$directory->isDir()) {
  26. continue;
  27. }
  28. $autoloader = $directory->getPathname() . '/vendor/autoload.php';
  29. if (file_exists($autoloader)) {
  30. require $autoloader;
  31. }
  32. }
  33. define('GANTRY_DEBUGGER', true);
  34. define('GANTRY5_DEBUG', true);
  35. define('GANTRY5_PLATFORM', 'grav');
  36. define('GANTRY5_ROOT', rtrim(ROOT_DIR, '/'));
  37. define('GANTRY5_VERSION', '@version@');
  38. define('GANTRY5_VERSION_DATE', '@versiondate@');
  39. define('GANTRYADMIN_PATH', '');