通过composer 安装swoft
- 全局镜像源更改:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
- 安装前准备
1,需要去除php.ini的禁用函数display_functions:proc_open,proc_get_status
2,需要安装resis扩展:
https://segmentfault.com/a/1190000020262177
- 安装
composer create-project swoft/swoft Swoft
- 启动
启动 HTTP 服务
$ php ./bin/swoft http:start
可能会报错:Class ‘Swoole\Coroutine’ not found,是swoole版本过低原因,把swoole更新一下就行
代码热更新,官方暂时支持swoftcli模式
只会检测部分文件夹: app 、config
安装cli注意:你需要替换 {VERSION} 部分。
wget https://github.com/swoft-cloud/swoft-cli/releases/download/{VERSION}/swoftcli.phar
启动http服务,会自动检测代码热更新,自动重新重启
php swoftcli.phar serve:run -c http:start