PHPackages                             aryeo/kafkaesque - 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. aryeo/kafkaesque

ActiveLibrary

aryeo/kafkaesque
================

An ergonomic interface for producing and consuming Kafka messages.

0.0.3(11mo ago)0690↓100%[4 PRs](https://github.com/AryeoHQ/kafkaesque/pulls)MITPHPPHP ^8.3CI passing

Since May 28Pushed 3mo agoCompare

[ Source](https://github.com/AryeoHQ/kafkaesque)[ Packagist](https://packagist.org/packages/aryeo/kafkaesque)[ Docs](https://github.com/aryeohq/kafkaesque)[ RSS](/packages/aryeo-kafkaesque/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (14)Versions (11)Used By (0)

Kafkaesque
==========

[](#kafkaesque)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a5cca6822b24e2873a337a2b4b60ed0fb338b96cc28e827e915706b7974a03ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617279656f68712f6b61666b6165737175652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aryeohq/kafkaesque)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2a20062a9ac242de5dc43e194d5f6f0474d532c261d42cc7c1b6561eeddce501/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617279656f68712f6b61666b6165737175652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/aryeohq/kafkaesque/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/90862aac980bde902a33f55e0deb876020da4f4d44b2f1083eacff1ab21c9f3f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617279656f68712f6b61666b6165737175652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/aryeohq/kafkaesque/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2c926e3036f992315243e43902ad3a0148653a5f092b610b41857055c5ce3fb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617279656f68712f6b61666b6165737175652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aryeohq/kafkaesque)

**Kafkaesque** is an ergonomic Laravel package that provides a clean, object-oriented interface for producing and consuming Apache Kafka messages. Built on top of the robust [mateusjunges/laravel-kafka](https://github.com/mateusjunges/laravel-kafka) package, Kafkaesque simplifies Kafka operations with environment-aware topic management, Avro schema registry integration, and type-safe message handling.

About the Package
-----------------

[](#about-the-package)

Kafkaesque abstracts the complexity of Kafka message handling by providing:

- **Environment-aware Topic Management**: Automatically handle topic names across different environments (local, development, staging, production)
- **Type-safe Message Schemas**: Built on Spatie's Laravel Data for robust data validation and serialization
- **Avro Schema Registry Integration**: Seamless integration with Confluent Schema Registry for schema evolution
- **Producer/Consumer Abstractions**: Clean interfaces for both message production and consumption
- **Flexible Architecture**: Contract-based design allowing easy extension and customization

The package follows Laravel conventions and integrates seamlessly with your existing Laravel applications.

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Laravel 10.45, 11.x, or 12.x
- ext-rdkafka extension

### Install the Package

[](#install-the-package)

Install via Composer:

```
composer require aryeo/kafkaesque
```

### Install the rdkafka Extension

[](#install-the-rdkafka-extension)

The package requires the `php-rdkafka` extension. Install it using:

```
# On macOS with Homebrew
brew install librdkafka
pecl install rdkafka

# On Ubuntu/Debian
sudo apt-get install librdkafka-dev
pecl install rdkafka

# On CentOS/RHEL
yum install librdkafka-devel
pecl install rdkafka
```

Add the extension to your `php.ini`:

```
extension=rdkafka
```

### Publish Configuration

[](#publish-configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="kafkaesque-config"
```

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

[](#configuration)

Configure your Kafka connection in your `.env` file:

```
KAFKA_BROKERS=localhost:9092
KAFKA_CONSUMER_GROUP_ID=your-app-group
KAFKA_SECURITY_PROTOCOL=PLAINTEXT
KAFKA_SASL_MECHANISMS=
KAFKA_SASL_USERNAME=
KAFKA_SASL_PASSWORD=

# For Avro Schema Registry (optional)
KAFKA_SCHEMA_REGISTRY_URL=http://localhost:8081
```

Message Schemas
---------------

[](#message-schemas)

Create message schemas using Spatie's Laravel Data. These schemas define the structure of your Kafka messages.

### Basic Schema

[](#basic-schema)

Start with a simple schema by extending `KafkaesqueSchema`:

```
