grav 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. require_once __DIR__ . '/../vendor/autoload.php';
  20. if (!ini_get('date.timezone')) {
  21. date_default_timezone_set('UTC');
  22. }
  23. if (!file_exists(ROOT_DIR . 'index.php')) {
  24. exit('FATAL: Must be run from ROOT directory of Grav!');
  25. }
  26. $app = new Application('Grav CLI Application', '0.1.0');
  27. $app->addCommands(array(
  28. new Grav\Console\Cli\InstallCommand(),
  29. new Grav\Console\Cli\ComposerCommand(),
  30. new Grav\Console\Cli\SandboxCommand(),
  31. new Grav\Console\Cli\CleanCommand(),
  32. new Grav\Console\Cli\ClearCacheCommand(),
  33. new Grav\Console\Cli\BackupCommand(),
  34. new Grav\Console\Cli\NewProjectCommand(),
  35. new Grav\Console\Cli\NewUserCommand(),
  36. ));
  37. $app->run();