站长资讯网
最全最丰富的资讯网站

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

本篇文章给大家带来了关于PHP的相关知识,其中主要跟大家介绍有关mac下pecl的扩展配置,本文是基于php7.4的,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

详解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 的原始扩展。

推荐学习:《PHP视频教程》

赞(0)
分享到: 更多 (0)