mac php多版本管理以及安装swoole扩展

mac多版本php管理

需要的工具

  • brew-php-switcher

安装php

安装php8.1


brew install shivammathur/php/php@8.1

安装php7.4


brew install shivammathur/php/php@7.4

安装brew-php-switcher


brew install brew-php-switcher

命令行多版本切换


brew-php-switcher 7.4 #切换到7.4
brew-php-switcher 8.0 #切换到8.1

我也不太清楚为什么 brew-php-switcher只提供了 到8.0版本的切换
但实际上我这里切换时,指定8.0会切换到8.1,可能是因为我本地并没有8.0的代码

安装扩展

切换完版本后就可以直接以 pecl命令安装扩展了,比如我要php8.1安装swoole


brew-php-switcher 8.1 #切换到8.1
#注意直接新开一个shell窗口,因为切换完成后当前活动窗口的php版本还没有改变
pecl install -D -D 'enable-sockets="no" enable-openssl="yes --with-openssl-dir=/usr/local/opt/openssl" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="no" enable-swoole-curl="yes" enable-cares="yes"'

等待命令安装成功后php -m | grep

在这里插入图片描述
ok

posted @ 2022-06-25 15:42  Death-Satan  阅读(329)  评论(0编辑  收藏  举报