wilbur-yu / hyperf-server-switch
0.0.2
2022-04-26 11:55 UTC
Requires
- php: >=8.0
- hyperf/command: ^2.0
- hyperf/contract: ^2.0
- hyperf/di: ^2.0
- hyperf/event: ^2.0
- symfony/console: ^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.14
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: >=7.0
- swoole/ide-helper: dev-master
- swow/swow: dev-develop
- symfony/var-dumper: ^5.1
README
搬运自: 如何让 Hyperf 只启动一个服务
安装
composer require wilbur-yu/hyperf-server-switch
配置
config/autoload/server.php
'servers' => [ [ 'name' => 'http', 'type' => Server::SERVER_HTTP, 'host' => '127.0.0.1', 'port' => 9801, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], ], [ 'name' => 'http2', 'type' => Server::SERVER_HTTP, 'host' => '0.0.0.0', 'port' => 9502, 'sock_type' => SWOOLE_SOCK_TCP, 'callbacks' => [ Event::ON_REQUEST => ['HttpServer2', 'onRequest'], ], ], ],
使用
- 启动所有 server
php bin/hyperf.php start
- 启动某个 server
php bin/hyperf.php -S http // or php bin/hyperf.php -S http2