gpm 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * @copyright Copyright (c) 2015 - 2024 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\GpmApplication;
  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. if (!file_exists(GRAV_ROOT . '/index.php')) {
  27. exit('FATAL: Must be run from ROOT directory of Grav!');
  28. }
  29. if (!function_exists('curl_version')) {
  30. exit('FATAL: GPM requires PHP Curl module to be installed');
  31. }
  32. $grav = Grav::instance(array('loader' => $autoload));
  33. $app = new GpmApplication('Grav Package Manager', GRAV_VERSION);
  34. $app->run();