forked from roadrunner-php/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrr
More file actions
84 lines (64 loc) · 1.98 KB
/
rr
File metadata and controls
84 lines (64 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env php
<?php
/**
* RoadRunner is a high-performance PHP application server, load-balancer,
* and process manager written in Golang.
*
* This file responsive for cli commands.
*/
declare(strict_types=1);
use Spiral\RoadRunner\Console\DownloadProtocBinaryCommand;
use Spiral\RoadRunner\Console\GetBinaryCommand;
use Spiral\RoadRunner\Console\MakeConfigCommand;
use Spiral\RoadRunner\Console\VersionsCommand;
use Spiral\RoadRunner\Version;
//
// Checking the PHP working environment.
//
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
$error = \vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
PHP_SAPI,
]);
\fwrite(STDERR, $error);
exit(1);
}
//
// Lookup the Composer's autoloader and require it.
//
$composerAutoloadPaths = [
// Install as dependency
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../../autoload.php',
__DIR__ . '/../autoload.php',
// Install as root package
__DIR__ . '/../vendor/autoload.php',
];
foreach ($composerAutoloadPaths as $file) {
if (\is_file($file)) {
\define('RR_COMPOSER_INSTALL', $file);
break;
}
}
if (! \defined('RR_COMPOSER_INSTALL')) {
\fwrite(STDERR, <<<'RR_CLI_ERROR'
You need to set up the project dependencies using Composer:
composer install
You can learn all about Composer on https://getcomposer.org/.
RR_CLI_ERROR);
exit(1);
}
require RR_COMPOSER_INSTALL;
$app = new Symfony\Component\Console\Application('RoadRunner CLI', Version::current());
if (method_exists($app, 'addCommand')) {
$app->addCommand(new GetBinaryCommand());
$app->addCommand(new VersionsCommand());
$app->addCommand(new DownloadProtocBinaryCommand());
$app->addCommand(new MakeConfigCommand());
} else {
// For Symfony 7.3 and lower
$app->add(new GetBinaryCommand());
$app->add(new VersionsCommand());
$app->add(new DownloadProtocBinaryCommand());
$app->add(new MakeConfigCommand());
}
$app->run();