环境: mac os x 10.10.3
[zcm@GatewayWorker 19]$php -v
PHP 7.2.5 (cli) (built: May 1 2018 09:50:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologieswith Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethanswith Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies
安装过程:
1. brew search proto
brew install protobuf@2.62. mvim ~/.bash_profile, 添加:
export PATH="/usr/local/opt/protobuf@2.6/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/protobuf@2.6/lib"
export CPPFLAGS="-I/usr/local/opt/protobuf@2.6/include"
export PKG_CONFIG_PATH="/usr/local/opt/protobuf@2.6/lib/pkgconfig"检测安装结果(重新打开终端窗口):
[zcm@~ 7]$which protoc
/usr/local/opt/protobuf@2.6/bin/protoc
[zcm@~ 8]$protoc --version
libprotoc 2.6.13. 下载并安装: allegro/php-protobuf
git clone https://github.com/allegro/php-protobuf
cd php-protobuf
composer install
phpize
./configure
make
make install4. 修改php配置文件
mvim /usr/local/etc/php/7.2/php.ini文件头添加:
extension="protobuf.so"5. 检测扩展是否安装成功
php -m | grep protobuf