Class 'RdKafka\\Conf' not found in Laravel

1.6k views Asked by At

I encounter an error using https://github.com/arnaud-lb/php-rdkafka

I followed the installation but still encounter an error using the class.

Installation process:

- sudo apt install php-pear

- sudo apt-get install -y librdkafka-dev

- sudo pecl install rdkafka

Enable PHP-extension in PHP config. Add to php.ini

sudo nano /etc/php/7.4/cli/php.ini

extension=rdkafka.so

Restart apache server

sudo service apache2 restart

Code :

    $conf = new \RdKafka\Conf();
    $conf->set('log_level', (string) LOG_DEBUG);
    $conf->set('debug', 'all');
    $rk = new \RdKafka\Producer($conf);
    $rk->addBrokers("10.0.0.1:9092,10.0.0.2:9092");

Composer.json

  "require": {
    "php": "^7.4",
    "ext-rdkafka": "*",
    ...

Error:

"Class 'RdKafka\\Conf' not found"

What's wrong with my installation? why RdKafka\Conf class not found?

0

There are 0 answers