装置php

装置php局部详见:https://github.com/shivammathur/homebrew-php

切换版本:

brew link --overwrite --force shivammathur/php/php@8.2

装置swoole

swoole间接用pecl装置,命令:pecl install swoole

但因为网络问题,常常会下载失败,能够间接用浏览器下载,而后用pecl装置。

下载地址:https://pecl.php.net/package/swoole
下载后运行:

pecl install /Users/cos800/Downloads/swoole-5.0.3.tgz

装置时候如果呈现:fatal error: 'pcre2.h' file not found
须要创立一个pcre2.h文件软链接:

ln -s /opt/homebrew/opt/pcre2/include/pcre2.h /opt/homebrew/opt/php@8.2/include/php/ext/pcre 

装置时候会询问是否启用各种反对,我目前是全默认。

启用swoole

装置完还要须要在php.ini中增加extension=swoole.so

1,查看php.ini文件所在位置:brew info php@8.2 会看到这一句:

The php.ini and php-fpm.ini file can be found in:    /opt/homebrew/etc/php/8.2/

或者执行:php --ini也能够看到。
2,间接用vscode关上目录:code /opt/homebrew/etc/php/8.2/
3,批改php.ini,找个喜爱的地位加上两行:

extension=swoole.soswoole.use_shortname = 'Off'

4,运行php -m|grep swoole,看到swoole就装置胜利了。

治理php-fpm服务

详见brew services -h
常见命令

# 启动brew services start php@8.2# 进行brew services stop php@8.2# 重启brew services restart php@8.2# 服务状态brew services info --all# 所有服务brew services list