gpm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env php
  2. <?php
  3. define('GRAV_CLI', true);
  4. if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
  5. exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
  6. }
  7. if (!file_exists(__DIR__ . '/../vendor')){
  8. require_once __DIR__ . '/../system/src/Grav/Common/Composer.php';
  9. }
  10. use Grav\Common\Composer;
  11. if (!file_exists(__DIR__ . '/../vendor')){
  12. // Before we can even start, we need to run composer first
  13. $composer = Composer::getComposerExecutor();
  14. echo "Preparing to install vendor dependencies...\n\n";
  15. echo system($composer.' --working-dir="'.__DIR__.'/../" --no-interaction --no-dev --prefer-dist -o install');
  16. echo "\n\n";
  17. }
  18. use Symfony\Component\Console\Application;
  19. use Grav\Common\Grav;
  20. $autoload = require_once(__DIR__ . '/../vendor/autoload.php');
  21. if (!ini_get('date.timezone')) {
  22. date_default_timezone_set('UTC');
  23. }
  24. if (!file_exists(ROOT_DIR . 'index.php')) {
  25. exit('FATAL: Must be run from ROOT directory of Grav!');
  26. }
  27. if (!function_exists('curl_version')) {
  28. exit('FATAL: GPM requires PHP Curl module to be installed');
  29. }
  30. $grav = Grav::instance(array('loader' => $autoload));
  31. $grav['config']->init();
  32. $grav['streams'];
  33. $grav['plugins']->init();
  34. $grav['themes']->init();
  35. $app = new Application('Grav Package Manager', GRAV_VERSION);
  36. $app->addCommands(array(
  37. new \Grav\Console\Gpm\IndexCommand(),
  38. new \Grav\Console\Gpm\VersionCommand(),
  39. new \Grav\Console\Gpm\InfoCommand(),
  40. new \Grav\Console\Gpm\InstallCommand(),
  41. new \Grav\Console\Gpm\UninstallCommand(),
  42. new \Grav\Console\Gpm\UpdateCommand(),
  43. new \Grav\Console\Gpm\SelfupgradeCommand(),
  44. ));
  45. $app->run();