These are chat archives for arnaud-lb/php-rdkafka

Oct 2018
Steven Lloyd
Oct 17 2018 15:15
Can anyone show me how to get a list of available topics?
Here is my failed attempt:
$md = new RdKafka\Metadata();
Steven Lloyd
Oct 17 2018 16:51
OK, figured it out. Here is a function to get the topics:
function kafkaGetTopics(){
    $pk = new RdKafka\Producer();
    $conf = new RdKafka\Conf();
    // Set the group id. This is required when storing offsets on the broker
    $conf->set('', 'yourspecialidgoeshere');
    $rk = new RdKafka\Consumer($conf);
    $sources = [$pk,$rk];
    $topics = [];
    foreach ($sources as $rdk) {
      $meta = $rdk->getMetadata(TRUE, null, 100);
      $rkTopics = $meta->getTopics();
      foreach ($rkTopics as $topic) {
        $topics[$topic->getTopic()] = TRUE;
    $keys = array_keys($topics);
    foreach($keys as $i=>$topic){
    return $topics;