mac下pecl的扩展如何配置

后端开发   发布日期:2024年04月20日   浏览次数:174

这篇文章主要介绍“mac下pecl的扩展如何配置”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“mac下pecl的扩展如何配置”文章能帮助大家解决问题。

mac 下 pecl 的 扩展配置 ( 基于php7.4 )

环境确认

如果你的php是通过brew安装的,一般情况下是带了pecl的。

$ pecl version
PEAR Version: 1.10.13
PHP Version: 7.4.28
Zend Engine Version: 3.4.0

如果没有,可以通过以下脚本安装。

安装脚本

$ curl -O https://pear.php.net/go-pear.phar
$ sudo php -d detect_unicode=0 go-pear.phar

pecl配置

查看pecl的相关配置

$ pecl config-show

这里可以看到pecl的默认扩展目录

PEAR executables directory     bin_dir          /opt/homebrew/lib/php/pecl/bin
PEAR documentation directory   doc_dir          /opt/homebrew/share/pear@7.4/doc
PHP extension directory        ext_dir          /opt/homebrew/Cellar/php@7.4/7.4.28_1/lib/php/20190902PEAR directory                 php_dir          /opt/homebrew/share/pear@7.4PEAR Installer cache directory cache_dir        /private/tmp/pear/cache
PEAR configuration file        cfg_dir          /opt/homebrew/lib/php/pecl/cfg

到扩展目录看以下

/opt/homebrew/Cellar/php@7.4/7.4.28_1/ [master*] ls -all | grep pecl
lrwxr-xr-x   1 yuan  admin      26  3 30 20:21 pecl -> /opt/homebrew/lib/php/pecl

很明显 安装扩展.so文件的目录是

/opt/homebrew/Cellar/php@7.4/7.4.28_1/pecl
,此目录实际上是软链接到了
/opt/homebrew/lib/php/pecl

目录配置

查看php的扩展目录

$ php -i | grep extension_dir
extension_dir => /opt/homebrew/lib/php/pecl/20190902

比如我安装了一个

yaml.so
扩展。
直接在
/opt/homebrew/etc/php/7.4/php.ini
中添加一行
yaml.so
,会自动在
/opt/homebrew/lib/php/pecl/20190902/yaml.so
找到软连接到
/opt/homebrew/Cellar/php@7.4/7.4.28_1/pecl/20190902/yaml.so
的原始扩展。

以上就是mac下pecl的扩展如何配置的详细内容,更多关于mac下pecl的扩展如何配置的资料请关注九品源码其它相关文章!