PHPackages                             fatihtuzlu/php-apache-kafka - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. fatihtuzlu/php-apache-kafka

ActiveLibrary

fatihtuzlu/php-apache-kafka
===========================

You can manage your multidata with this package

v1.0.0(2y ago)010MITPHPPHP ^8.0

Since Mar 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/tuzlu07x/php-apache-kafka)[ Packagist](https://packagist.org/packages/fatihtuzlu/php-apache-kafka)[ RSS](/packages/fatihtuzlu-php-apache-kafka/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHP Apache Kafka Package
========================

[](#php-apache-kafka-package)

PHP Kafka CDC is a package developed by Fatih Tuzlu for managing multidata with Apache Kafka in PHP applications. It provides functionalities for both consuming and producing messages using Kafka.

Remember
--------

[](#remember)

Do not forget to install rdkafka library

### Macos

[](#macos)

```
brew install librdkafka

```

### Debian

[](#debian)

```
$ apt install librdkafka-dev

```

### RedHat, CentOS, Fedora

[](#redhat-centos-fedora)

```
$ yum install librdkafka-devel

```

### Windows

[](#windows)

```
# Install vcpkg if not already installed
$ git clone https://github.com/Microsoft/vcpkg.git
$ cd vcpkg
$ ./bootstrap-vcpkg.sh
$ ./vcpkg integrate install

# Install librdkafka
$ vcpkg install librdkafka

```

### For Detail

[](#for-detail)

```
You can visit https://github.com/confluentinc/librdkafka

```

Installation
------------

[](#installation)

You can install PHP Kafka CDC via Composer. Run the following command in your terminal:

```
composer require fatihtuzlu/php-apache-kafka

```

Requirements
------------

[](#requirements)

PHP Kafka CDC requires the following dependencies:

```
idealo/php-rdkafka-ffi: ^0.5.0
php: ^8.0.0

```

Usage
-----

[](#usage)

### Consumer

[](#consumer)

To consume messages from Kafka topics, you can use the ConsumerManager class. Here's a basic example of how to set up a consumer:

```
use Fatihtuzlu\PHPKafkaCDC\ConsumerManager;

// Initialize consumer manager
$consumer = new ConsumerManager(
    $topic,       // Kafka topic to consume from
    $groupId,     // Consumer group ID
    $bootstrapServers // Kafka bootstrap servers
);

// Fetch messages from Kafka
$message = $consumer->fetchMessages($topic, $partition, $offset, $timeMs);
```

### Producer

[](#producer)

To produce messages to Kafka topics, you can use the ProducerManager class. Here's a basic example of how to set up a producer:

```
use Fatihtuzlu\PHPKafkaCDC\ProducerManager;

// Initialize producer manager
$producer = new ProducerManager(
    $topic,             // Kafka topic to produce to
    $bootstrapServers   // Kafka bootstrap servers
);

// Send a message to Kafka
$producer->sendMessages($message, $flush = 1000, $debug = false);
```

Configuration
-------------

[](#configuration)

### Debugging

[](#debugging)

You can enable debugging for your Kafka connection by calling the debug() method:

```
$producer->debug();
```

### Additional Brokers

[](#additional-brokers)

```
$producer->addBrokers($brokerList);
```

Examples
--------

[](#examples)

### Sample Consumer

[](#sample-consumer)

```
use Fatihtuzlu\PHPKafkaCDC\ConsumerManager;

// Kafka broker and topic information
$bootstrapServers = "localhost:9092";
$topic = "my_topic";
$groupId = "my_group";

// Initialize the consumer
$consumer = new ConsumerManager($topic, $groupId, $bootstrapServers);

// Fetch messages
$message = $consumer->fetchMessages($topic, 0, RD_KAFKA_OFFSET_BEGINNING);

// Process the received message
if ($message !== null) {
    echo "Received message: " . $message->payload . "\n";
} else {
    echo "No messages available.\n";
}
```

### Sample Producer

[](#sample-producer)

```
use Fatihtuzlu\PHPKafkaCDC\ProducerManager;

// Kafka broker and topic information
$bootstrapServers = "localhost:9092";
$topic = "my_topic";

// Initialize the producer
$producer = new ProducerManager($topic, $bootstrapServers);

// Send a message
$messageToSend = "Hello, Kafka!";
$producer->sendMessages($messageToSend);

echo "Message sent to Kafka: " . $messageToSend . "\n";
```

In these examples, the consumer retrieves messages from Kafka, while the producer sends messages to Kafka. my\_topic represents the target topic in Kafka. Make sure to update the configuration settings according to your own Kafka cluster.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

800d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c883222589152dfc614d8ddcb1a872208be25fd07246d2b9f2b2d3741ebf9876?d=identicon)[tuzlu07x](/maintainers/tuzlu07x)

---

Top Contributors

[![tuzlu07x](https://avatars.githubusercontent.com/u/86893131?v=4)](https://github.com/tuzlu07x "tuzlu07x (10 commits)")

### Embed Badge

![Health badge](/badges/fatihtuzlu-php-apache-kafka/health.svg)

```
[![Health](https://phpackages.com/badges/fatihtuzlu-php-apache-kafka/health.svg)](https://phpackages.com/packages/fatihtuzlu-php-apache-kafka)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
