plugins-bootstrap.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. }