Skip to content

Commit

Permalink
Merge pull request #32 from huangzhhui/reverse-proxy
Browse files Browse the repository at this point in the history
Rename the `start` command to `reverse-proxy` command
  • Loading branch information
huangzhhui authored Oct 2, 2022
2 parents 9f33468 + 7bf56e6 commit 87f379c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Box 需要一个 Github 访问令牌来请求 Github API,以检索包的版本
- `box config unset <key>`按 key 删除配置值
- `box config set-php-version <version>`设置 box 的当前 PHP 版本,可用值:8.0 | 8.1
- `box config get-php-version <version>`获取 box 的当前设置的 PHP 版本
- `box start -u <upsteamHost:upstreamPort>` 为上游服务器启动代理 HTTP 服务器
- `box reverse-proxy -u <upsteamHost:upstreamPort>` 启动一个反向代理 HTTP 服务器,用于将 HTTP 请求转发到指定的多个上游服务器
- `box php <argument>` 通过当前 box 的 PHP 版本运行任何 PHP 命令
- `box composer <argument>`通过当前 box 的 PHP 版本运行任何 Composer 命令,composer bin 的版本取决于最后执行的`get composer`命令
- `box php-cs-fixer <argument>` 通过当前 box 的 PHP 版本运行任何 php-cs-fixer 命令,composer bin 的版本取决于最后执行的 `get php-cs-fixer` 命令
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Box needs a Github Access Token to request github api, to retrieve the versions
- `box config unset <key>` to unset the config value by key
- `box config set-php-version <version>` to set the current PHP version of box, available value: 8.0 | 8.1
- `box config get-php-version <version>` to get the current PHP version of box
- `box start -u <upsteamHost:upstreamPort>` to start a proxy HTTP server for the upstream server
- `box reverse-proxy -u <upsteamHost:upstreamPort>` to start a reverse proxy HTTP server for the upstream servers
- `box php <argument>` to run any PHP command via current PHP version of box
- `box composer <argument>` to run any Composer command via box, the version of the composer bin depends on the last executed `get composer` command
- `box php-cs-fixer <argument>` to run any php-cs-fixer command via box, the version of the composer bin depends on the last executed `get php-cs-fixer` command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
use Symfony\Component\Console\Input\InputOption;

#[Command]
class StartCommand extends HyperfCommand
class ReverseProxyCommand extends HyperfCommand
{
public function __construct(protected ContainerInterface $container)
{
parent::__construct('start');
parent::__construct('reverse-proxy');
}

public function configure()
{
parent::configure();
$this->setDescription('Start the sidecar server.');
$this->addOption('host', '', InputOption::VALUE_OPTIONAL, 'The host of proxy server', '127.0.0.1');
$this->addOption('port', 'p', InputOption::VALUE_OPTIONAL, 'The port of proxy server', 9764);
$this->addOption('backlog', '', InputOption::VALUE_OPTIONAL, 'The backlog of proxy server', Socket::DEFAULT_BACKLOG);
$this->addOption('upstream', 'u', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'The target upstream servers of proxy server', []);
$this->setDescription('Start the reverse proxy server for upstreams.');
$this->addOption('host', '', InputOption::VALUE_OPTIONAL, 'The host of the reverse proxy server', '127.0.0.1');
$this->addOption('port', 'p', InputOption::VALUE_OPTIONAL, 'The port of the reverse proxy server', 9764);
$this->addOption('backlog', '', InputOption::VALUE_OPTIONAL, 'The backlog of the reverse proxy server', Socket::DEFAULT_BACKLOG);
$this->addOption('upstream', 'u', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'The target upstream servers of the reverse proxy server', []);
}

public function handle()
Expand All @@ -60,7 +60,7 @@ public function handle()

$server = new HttpServer();
$server->bind($host, $port)->listen($backlog);
$this->output->writeln(sprintf('<info>[INFO] Proxy Server listening at %s:%d</info>', $host, $port));
$this->output->writeln(sprintf('<info>[INFO] Reverse Proxy Server listening at %s:%d</info>', $host, $port));
while (true) {
try {
$connection = $server->acceptConnection();
Expand Down

0 comments on commit 87f379c

Please sign in to comment.