rr 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * RoadRunner is a high-performance PHP application server, load-balancer,
  5. * and process manager written in Golang.
  6. *
  7. * This file responsive for cli commands.
  8. */
  9. declare(strict_types=1);
  10. use Spiral\RoadRunner\Console\DownloadProtocBinaryCommand;
  11. use Spiral\RoadRunner\Console\GetBinaryCommand;
  12. use Spiral\RoadRunner\Console\MakeConfigCommand;
  13. use Spiral\RoadRunner\Console\VersionsCommand;
  14. use Spiral\RoadRunner\Version;
  15. //
  16. // Checking the PHP working environment.
  17. //
  18. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  19. $error = vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
  20. PHP_SAPI,
  21. ]);
  22. fwrite(STDERR, $error);
  23. exit(1);
  24. }
  25. //
  26. // Lookup the Composer's autoloader and require it.
  27. //
  28. $composerAutoloadPaths = [
  29. // Install as dependency
  30. __DIR__ . '/../../../autoload.php',
  31. __DIR__ . '/../../autoload.php',
  32. __DIR__ . '/../autoload.php',
  33. // Install as root package
  34. __DIR__ . '/../vendor/autoload.php',
  35. ];
  36. foreach ($composerAutoloadPaths as $file) {
  37. if (is_file($file)) {
  38. define('RR_COMPOSER_INSTALL', $file);
  39. break;
  40. }
  41. }
  42. if (! defined('RR_COMPOSER_INSTALL')) {
  43. fwrite(STDERR, <<<'RR_CLI_ERROR'
  44. You need to set up the project dependencies using Composer:
  45. composer install
  46. You can learn all about Composer on https://getcomposer.org/.
  47. RR_CLI_ERROR);
  48. exit(1);
  49. }
  50. require RR_COMPOSER_INSTALL;
  51. $app = new Symfony\Component\Console\Application('RoadRunner CLI', Version::current());
  52. $app->add(new GetBinaryCommand());
  53. $app->add(new VersionsCommand());
  54. $app->add(new DownloadProtocBinaryCommand());
  55. $app->add(new MakeConfigCommand());
  56. $app->run();