This package is abandoned and no longer maintained. The author suggests using the nirmalsharma/laravel-kafka-producer package instead.

1.0.5 2022-12-23 09:28 UTC

This package is auto-updated.

Last update: 2022-12-23 09:30:07 UTC


README

Install Kafka Producer Warpper

  composer require nirmalsharma/laravel-kafka-producer

Examples

Laravel 6

Use Kafka in code.

Add following in web.php

use KafkaProducer;

$topic = "kafka-topic";
$data = [
    "user_ref" => "usr.123456",
    "message" => "Hello World"
];
$key = "usr.123456"; // Optional, Default null
$headers = [
    "ContentType" => "application/json",
    "Timezone" => "GMT +05:30"
]; // Optional
Kafka::push($topic, $data, $key, $headers);

Environment Variables

To run this, you will need to add the following environment variables to your .env file Config reference: https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

IS_KAFKA_ENABLED=             // Default:  1
KAFKA_BROKERS=
KAFKA_DEBUG=                  // Default: false
KAFKA_SSL_PROTOCOL=           // Default: plaintext
KAFKA_COMPRESSION_TYPE=       // Default: none
KAFKA_IDEMPOTENCE=            // Default: false

Authors

License

MIT

Features

  • Light weight kakfa wrapper
  • Easy to use event produce in code.