grav 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env php
  2. <?php
  3. define('GRAV_CLI', true);
  4. if (!file_exists(__DIR__ . '/../vendor')){
  5. require_once __DIR__ . '/../system/src/Grav/Common/Composer.php';
  6. }
  7. use Grav\Common\Composer;
  8. if (!file_exists(__DIR__ . '/../vendor')){
  9. // Before we can even start, we need to run composer first
  10. $composer = Composer::getComposerExecutor();
  11. echo "Preparing to install vendor dependencies...\n\n";
  12. echo system($composer.' --working-dir="'.__DIR__.'/../" --no-interaction --no-dev --prefer-dist -o install');
  13. echo "\n\n";
  14. }
  15. use Symfony\Component\Console\Application;
  16. require_once __DIR__ . '/../vendor/autoload.php';
  17. if (version_compare($ver = PHP_VERSION, $req = GRAV_PHP_MIN, '<')) {
  18. exit(sprintf("You are running PHP %s, but Grav needs at least PHP %s to run.\n", $ver, $req));
  19. }
  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', GRAV_VERSION);
  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\SecurityCommand(),
  36. ));
  37. $app->run();