horizom / dev-server
支持多进程和TLS/SSL加密的PHP内置服务器反向代理
3.1.0
2022-08-23 14:00 UTC
Requires
- php: >=7.0.0
- lib-openssl: *
- react/child-process: ^0.4.1
- react/promise: ^2.4
This package is not auto-updated.
Last update: 2024-10-02 22:25:06 UTC
README
Horizom Dev Server
支持多进程和TLS/SSL加密的PHP内置服务器反向代理。
安装
全局安装
composer global require horizom/dev-server
如果尚未添加,您必须将 ~/.composer/vendor/bin
添加到 $PATH
。
将以下语句追加到 ~/.bashrc
、~/.zshrc
或其他类似文件中。
export PATH="$HOME/.composer/vendor/bin:$PATH"
仅针对开发环境进行本地安装
composer require --dev horizom/dev-server
使用 vendor/bin/horizom-serve
作为执行路径。
用法
快速开始
horizom-serve -S localhost -s localhost -t public
将启动2个服务器,以 public
目录作为文档根目录
https://:8000
https://:44300
服务器将以方案依赖的范围内第一个未被占用的端口号启动。
自定义端口号
horizom-serve -S localhost:8080 -s localhost:4000 -t public
将启动2个服务器,以 public
目录作为文档根目录
https://:8080
https://:4000
命令参考
mpyw@localhost:~$ horizom-serve -h Usage: horizom-serve <options> Example: horizom-serve -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/username/.composer/vendor/horizom/dev-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. username@localhost:~$
Windows用户注意事项
遗憾的是,cmd.exe
没有通过shebang #!/usr/bin/env php
运行的选项,因此您需要在正确的目录中创建以下批处理文件。
针对独立PHP
@echo OFF "C:\php\php.exe" "%HOMEPATH%\.composer\vendor\horizom\dev-server\horizom-serve" %*
针对XAMPP
@echo OFF "C:\xampp\php\php.exe" "%HOMEPATH%\.composer\vendor\horizom\dev-server\horizom-serve" %*