详解mac下pecl的扩展配置(附代码实例)-全球热资讯

来源:php中文网 | 2023-03-25 17:48:35 |

本篇文章给大家带来了关于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的扩展配置(附代码实例)的详细内容,更多请关注php中文网其它相关文章!

关键词: