mpyw / php-hyper-builtin-server
支持多进程和TLS/SSL加密的PHP内置服务器反向代理
v3.1.0
2020-06-02 21:11 UTC
Requires
- php: >=5.4.0
- lib-openssl: *
- react/child-process: ^0.4.1
- react/promise: ^2.4
Requires (Dev)
- php: >=7.0.0
- codeception/aspect-mock: ^2.0
- codeception/codeception: ^2.2
- codeception/specify: ^0.4.6
- mpyw/co: ^1.5
- mpyw/privator: ^2.0
- satooshi/php-coveralls: ^1.0
README
支持多进程和TLS/SSL加密的PHP内置服务器反向代理。
安装
全局安装
composer global require mpyw/php-hyper-builtin-server:^3.0
如果尚未安装,您必须将 ~/.composer/vendor/bin
添加到 $PATH
。
将以下语句追加到 ~/.bashrc
、~/.zshrc
或其他配置文件。
export PATH="$HOME/.composer/vendor/bin:$PATH"
仅针对开发环境的本地安装
composer require --dev mpyw/php-hyper-builtin-server:^3.0
使用 vendor/bin/hyper-run
作为执行路径。
用法
快速开始
hyper-run -S localhost -s localhost -t src/app/www
将启动2个服务器,以 src/app/www
目录作为文档根目录
http://localhost:8000
https://localhost:44300
服务器将使用指定方案范围内的第一个未占用端口启动
自定义端口
hyper-run -S localhost:8080 -s localhost:4000 -t src/app/www
将启动2个服务器,以 src/app/www
目录作为文档根目录
http://localhost:8080
https://localhost:4000
命令参考
mpyw@localhost:~$ hyper-run -h Usage: hyper-run <options> Example: hyper-run -S localhost:8000 -s localhost:44300 [Required] -S "<Host>:<Port>" of an HTTP server. Multiple arguments can be accepted. -s "<Host>:<Port>" of an HTTPS server. Multiple arguments can be accepted. [Optional] -n The number of PHP built-in server clusters, from 1 to 20. Default is 10. -t Path for the document root. Default is the current directory. -r Path for the router script. Default is empty. -c Path for the PEM-encoded certificate. Default is "/Users/mpyw/.composer/vendor/mpyw/php-hyper-builtin-server/certificate.pem". Restrictions: - The option -s is only supported on PHP 5.6.0 or later. - Access logs will not be displayed on Windows. mpyw@localhost:~$
Windows用户注意事项
遗憾的是,cmd.exe
没有通过shebang #!/usr/bin/env php
运行的选项,因此您需要在正确目录中创建以下批处理文件。
针对独立PHP
@echo OFF "C:\php\php.exe" "%HOMEPATH%\.composer\vendor\mpyw\php-hyper-builtin-server\hyper-run" %*
针对XAMPP
@echo OFF "C:\xampp\php\php.exe" "%HOMEPATH%\.composer\vendor\mpyw\php-hyper-builtin-server\hyper-run" %*