1. 先安装 curl 依赖(必须)
bash
运行
brew install curl
2. 复制这一整段直接运行(自动找你的 PHP、自动编译)
bash
运行
cd /tmp
rm -rf yar
git clone https://github.com/laruence/yar.git
cd yar
$(which phpize)
./configure --with-php-config=$(which php-config) \
--with-curl=/opt/homebrew/opt/curl \
CFLAGS="-I/opt/homebrew/opt/c/include" \
LDFLAGS="-L/opt/homebrew/opt/curl/lib"
make && make install
3. 启用扩展 + 验证
bash
运行
echo "extension=yar.so" >> $(php --ini | grep "Loaded Configuration File" | awk '{print $4}')
php -m | grep yar