Looking to hire Laravel developers? Try LaraJobs

laravel-kafka-producer maintained by nirmalsharma

Last update
2022/12/23 10:28 (dev-master)
License
Links
Downloads
76

Comments
comments powered by Disqus

A Lightweight Kafka Producer Warpper for Laravel 6+ and PHP 7.3+

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.