Open yunkaiyueming opened 9 years ago
when i use phpkafka function in my php file:
" Fatal error: Class 'Kafka' not found in /usr/local/www/kafka-php/test_kafka.php on line 5 "
I know i havn't install phpkafka into php_extension rightly, how can i solve it?
Running following commands to load the shared library folder in env variables solved this for me
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
@the100rabh : thanks for your answer, i have solved this problem, i have compiled the 'phpkafka' into php_extension, when i use the next code into my php file:
test_phpkafka.php <?php ini_set('display_errors',TRUE); error_reporting(E_ALL); set_time_limit(0);
$kafka = new Kafka("localhost:9092"); $kafka->produce("topic_name", "message content"); $kafka->consume("topic_name", 1172556); ?>
new 'Kafka' is ok, var_dump($kafka) is : object(Kafka)#1 (0) { } but '$kafka->produce' and '$kafka->consume' give nothing ,untile nginx server response 502, what's wrong?
I too tried using consume function thats the one that gives the issue. produce works fine.
@yunkaiyueming The problem is that this extension, ATM still requires you to specify what partition to consume from. I'm working on a fix for that, though. for now, you can use my fork (consume-with-meta
branch), which adds a couple of methods like getPartitionsForTopic
that enable you to set the partition correctly before consuming
salebab's repo has been abandoned, I've forked it and I'm developing it further. Currently, the consume-with-meta branch is the one that is most up-to-date. If you have any issues/suggestions, you can create an issue on my fork, as my changes will probably not get merged (there's a PR ready and waiting, but the owner, salebab, hasn't merged them, instead, he's updated the README file, linking to my fork).
If you want, you can use my fork for testing, mind you, it's far from being stable
On Tue, Apr 7, 2015 at 11:48 PM, eparisca notifications@github.com wrote:
@EVODelavega https://github.com/EVODelavega Do you have an estimate on when you will merge that fork's features? Thank you very much!
— Reply to this email directly or view it on GitHub https://github.com/salebab/phpkafka/issues/6#issuecomment-90742146.
@EVODelavega Hi EVODelavega, I installed phpkafka in CentOS 6.5 by these commands: ldconfig /usr/bin/phpize ./configure --enable-kafka --with-php-config=/usr/bin/php-config make make install
then I can see kafka.so under /usr/lib64/php/modules.
but when I executed 'service php-fpm restart', it told me: Starting php-fpm: [16-Oct-2015 17:07:23] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
I have tried export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib as well, but it still not work.
Could you give me some suggestion about it? Thanks!
@siyuanmami Not sure, I know there were some issues with building librdkafka on CentOS some time ago, so maybe you want to check the issues on edenhill's librdkafka repo. So far, I've only tested the extension on debian, Slackware, mint and ubuntu. I haven't seen the issue you're reporting on any of those systems, though
@EVODelavega Thanks for your help. I have confirmed with edenhill about it, I should have installed librdkafka library correctly. Not sure if it is because I am using php-fpm. I used to install this extension on ubuntu worked with apache, it is fine.
Thanks!
@siyuanmami php-fpm shouldn't be an issue. AFAIK, it handles the MINIT, RINIT, RSHUTDOWN and MSHUTDOWN cycles in exactly the same way, and as it stands, there's very little in the module init and shutdown functions that could trip PHP up. But having said that: what version are you currently using? What repo, what branch?
@EVODelavega This seems to come up quite often, librdkafka.so.1 not being in the library search for the PHP invociation and people dont really know how to fix it, so may I suggest you add some instructions in README?
@EVODelavega Thanks you for you help! I have installed the php extension successfully after I updated /etc/ld.so.conf to include /usr/local/lib !
@edenhill Done, added some instructions that should be rather dummy-proof to the README on current master
Thanks @the100rabh your solution helped me get kafkacat working.
I fixed it finally on CentOS 7!! For both CLI and FPM
echo '/usr/local/lib' > /etc/ld.so.conf.d/kafka.conf
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/php/modules:/usr/local/lib"' >> /etc/profile
ldconfig
@abdollahpour I had tried above command that you told but that is also not working. Still I am getting same error. Could you please tell me what else step you taken to resolve that issue. Thank You!!!
when i 'make' phpkafka, it occured the followed issue:
[root@OA-test phpkafka]# make test Build complete. Don't forget to run 'make test'.
PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0
how can i solve it??? please help me