grav 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @copyright Copyright (c) 2015 - 2023 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\GravApplication;
  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. // Set timezone to default, falls back to system if php.ini not set
  22. date_default_timezone_set(@date_default_timezone_get());
  23. // Set internal encoding.
  24. @ini_set('default_charset', 'UTF-8');
  25. mb_internal_encoding('UTF-8');
  26. $grav = Grav::instance(array('loader' => $autoload));
  27. if (!file_exists(GRAV_ROOT . '/index.php')) {
  28. exit('FATAL: Must be run from ROOT directory of Grav!');
  29. }
  30. $app = new GravApplication('Grav CLI Application', GRAV_VERSION);
  31. $app->run();