Skip to main content
Winter Kafka is a module that provides easy configuration and access to Kafka functionality from Winter Boot applications. It takes care of wiring producers and consumer workers into the framework lifecycle, so you can send and receive events with only YAML configuration and focused worker classes.
1

Install PHP extensions

Winter Kafka needs swoole and rdkafka installed via PECL.
2

Require the module

Add the modules package with Composer.
3

Enable in application.yml

Register the module and point it to your config file.
configFile is a file path relative to your config directory or an absolute path.

kafka-config.yml

The Kafka config declares your bootstrap servers, consumer groups, and named producers. You can apply global defaults with the reserved __default__ name and override per group or producer as needed.

Autowired services

KafkaService is available to applications by default. Consumer workers start automatically when the framework boots, and all producers are enabled by default. The reserved "__default__" consumer and producer entries can contain any rdkafka settings. Defaults apply to all producers and consumers; each individual entry may also specify its own rdkafka settings, which apply only to that producer or consumer.

Consumer properties

Producer properties

How to write a consumer worker

A consumer worker must implement the Consumer interface. In practice, extend AbstractConsumer and implement the consume method.
Related modules: SQS for AWS-managed queues and DTCE for task orchestration with a Kafka-backed queue.