您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

详解mac下pecl的扩展配置(附代码实例)

2026/2/4 21:05:43发布13次查看
本篇文章给大家带来了关于php的相关知识,其中主要跟大家介绍有关mac下pecl的扩展配置,本文是基于php7.4的,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。
mac 下 pecl 的 扩展配置 ( 基于php7.4 )
环境确认
如果你的php是通过brew安装的,一般情况下是带了pecl的。
$ pecl versionpear version: 1.10.13php version: 7.4.28zend 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/binpear documentation directory doc_dir /opt/homebrew/share/pear@7.4/docphp 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/cachepear configuration file cfg_dir /opt/homebrew/lib/php/pecl/cfg
到扩展目录看以下
/opt/homebrew/cellar/php@7.4/7.4.28_1/ [master*] ls -all | grep pecllrwxr-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_dirextension_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 的原始扩展。
推荐学习:《php视频教程》
以上就是详解mac下pecl的扩展配置(附代码实例)的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product