salebab / phpkafka

PHP extension for Apache Kafka
MIT License
17 stars 66 forks source link

PHP Fatal error: Class 'Kafka' not found in /var/www/html/kafka-test.php on line 3 #11

Closed camilo-escobar closed 8 years ago

camilo-escobar commented 8 years ago

Hello,

I already install both phpkafka and librdkafka and it seems that the installation went well. Even following the steps you suggested in README.md I solved the problem of "Unable to load dynamic library '/usr/lib64/php/modules/kafka.so' - librdkafka.so.1".

Now, when I try to execute the sample code I get this error "PHP Fatal error: Class 'Kafka' not found in /var/www/html/kafka-test.php on line 3"

What am I missing? Why PHP does not recognize the class Kafka? Is there some specific place where I have to put my code within my public directory?

The code I'm using is below, I really appreciate any help on this.

<?php // Produce a message $kafka = new Kafka("localhost:9092"); $kafka->produce("topic_name", "message content"); //get all the available partitions $partitions = $kafka->getPartitionsForTopic('topic_name'); //use it to OPTIONALLY specify a partition to consume from //if not, consuming IS slower. To set the partition: $kafka->setPartition($partitions[0]);//set to first partition //then consume, for example, starting with the first offset, consume 20 messages $msg = $kafka->consume("topic_name", Kafka::OFFSET_BEGIN, 20); var_dump($msg);//dumps array of messages

camilo-escobar commented 8 years ago

Sorry, this issue is not related with this project, what I'm using is the PHP client https://github.com/EVODelavega/phpkafka,I get confused with the repository and wrote the issue in the wrong place.

BTW, I'm gonna try this salebab/phpkafka library.

I'm desperately looking for a PHP Kafka Client that works, I have had different problems with those I have used.

Closed it.