PHP使用Kafka

安装php扩展

//http://pecl.php.net/
//在php扩展上下载合适的rdkafka包

wget http://pecl.php.net/get/rdkafka-4.0.3.tgz
tar xvf rdkafka-4.0.3.tgz
cd rdkafka-4.0.3
/path/to/phpize
./configure --with-php-config=/path/to/php-config
make && make install

....
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for rdkafka support... yes, shared
checking for librdkafka/rdkafka.h" in default path... not found
configure: error: Please reinstall the rdkafka distribution


//发现报错缺少一个依赖:librdkafka 

git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
./configure
make && make install

//接着  make && make install   安装完成
//在php.ini  添加 rdkafka.so

安装composer包

https://github.com/weiboad/kafka-php/blob/master/README_CH.md

鲁ICP备16017569号-2