plugin 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
  5. * @license MIT License; see LICENSE file for details.
  6. */
  7. use Grav\Common\Composer;
  8. use Grav\Common\Grav;
  9. use Grav\Console\Application\PluginApplication;
  10. \define('GRAV_CLI', true);
  11. \define('GRAV_REQUEST_TIME', microtime(true));
  12. if (!file_exists(__DIR__ . '/../vendor/autoload.php')){
  13. // Before we can even start, we need to run composer first
  14. require_once __DIR__ . '/../system/src/Grav/Common/Composer.php';
  15. $composer = Composer::getComposerExecutor();
  16. echo "Preparing to install vendor dependencies...\n\n";
  17. echo system($composer.' --working-dir="'.__DIR__.'/../" --no-interaction --no-dev --prefer-dist -o install');
  18. echo "\n\n";
  19. }
  20. $autoload = require __DIR__ . '/../vendor/autoload.php';
  21. if (!ini_get('date.timezone')) {
  22. date_default_timezone_set('UTC');
  23. }
  24. // Set internal encoding.
  25. if (!\extension_loaded('mbstring')) {
  26. die("'mbstring' extension is not loaded. This is required for Grav to run correctly");
  27. }
  28. @ini_set('default_charset', 'UTF-8');
  29. mb_internal_encoding('UTF-8');
  30. if (!file_exists(GRAV_ROOT . '/index.php')) {
  31. exit('FATAL: Must be run from ROOT directory of Grav!');
  32. }
  33. // Bootstrap Grav container.
  34. $grav = Grav::instance(array('loader' => $autoload));
  35. $app = new PluginApplication('Grav Plugins Commands', GRAV_VERSION);
  36. $app->run();