Download the PHP package micromus/kafka-bus-domain without Composer
On this page you can find all versions of the php package micromus/kafka-bus-domain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download micromus/kafka-bus-domain
More information about micromus/kafka-bus-domain
Files in micromus/kafka-bus-domain
Package kafka-bus-domain
Short Description Messages Builder for Kafka Bus
License MIT
Homepage https://github.com/micromus/kafka-bus-messages
Informations about the package kafka-bus-domain
Kafka Bus Messages for PHP
A PHP library for structuring, serializing, and deserializing Kafka messages. It provides typed message payloads with automatic casting, domain event messages, and factory helpers for both production and testing.
Installation
Core Concepts
Payload— a flexible key-value container that supports typed attribute casting (dates, integers, floats, nested payloads, collections).JsonMessage— aPayloadthat serializes itself directly to a JSON Kafka message.DomainMessage— a structured message that wraps an attributes object with a domain event type (create,update,delete) and a list of dirty (changed) fields.- Casters — classes that convert raw values on read (
cast) and convert them back for serialization (rollback).
Usage
1. Defining a Domain Message
Extend Payload and define casters in definitionCasters() to type your fields automatically.
2. Available Casters
| Caster | Description |
|---|---|
IntegerCaster |
Casts value to int |
FloatCaster |
Casts value to float |
DateTimeCaster |
Parses/formats DateTimeInterface with a configurable format |
PayloadCaster |
Hydrates a nested Payload subclass from an array |
CollectionCaster |
Applies another caster to each item in an array |
NullableCaster |
Wraps any caster to allow null values |
3. Sending a JSON Message
JsonMessage extends Payload and implements ProducerMessageInterface, so it can be published directly to Kafka.
4. Sending a Domain Message
DomainMessage wraps an attributes object with a domain event type and a list of changed fields.
5. Consuming a Domain Message
Use DomainMessageFactory to deserialize an incoming Kafka message into a typed DomainMessage.
6. Testing Helpers
The library ships with factory base classes to generate realistic test data via Faker.
Define a test factory:
Use it in tests:
For payload-only factories, extend PayloadTestFactory:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Kirill Popkov
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of kafka-bus-domain with dependencies
ext-rdkafka Version *
micromus/kafka-bus Version ^1.0.0
webmozart/assert Version ^1.11|^2.0