本篇文章給大家?guī)砹岁P(guān)于PHP的相關(guān)知識,其中主要跟大家介紹有關(guān)mac下pecl的擴展配置,本文是基于php7.4的,感興趣的朋友下面一起來看一下吧,希望對大家有幫助。
mac 下 pecl 的 擴展配置 ( 基于php7.4 )
環(huán)境確認
如果你的php是通過brew安裝的,一般情況下是帶了pecl的。
$ pecl version PEAR Version: 1.10.13 PHP Version: 7.4.28 Zend Engine Version: 3.4.0
登錄后復(fù)制
如果沒有,可以通過以下腳本安裝。
安裝腳本
$ curl -O https://pear.php.net/go-pear.phar $ sudo php -d detect_unicode=0 go-pear.phar
登錄后復(fù)制
pecl配置
查看pecl的相關(guān)配置
$ pecl config-show
登錄后復(fù)制
這里可以看到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
登錄后復(fù)制
到擴展目錄看以下
/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
登錄后復(fù)制
很明顯 安裝擴展.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
登錄后復(fù)制
比如我安裝了一個 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
的原始擴展。
推薦學(xué)習(xí):《PHP視頻教程》