PHP code example of sadegh2007 / laravel_queue_kafka

1. Go to this page and download the library: Download sadegh2007/laravel_queue_kafka library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sadegh2007 / laravel_queue_kafka example snippets


'connections' => [
    // ...

    'kafka' => [
        'driver' => 'kafka',
        'sleep_on_error' => env('KAFKA_SLEEP_ON_ERROR', 5),
        'topics' => env('KAFKA_TOPICS', 'default'),
        'debug' => env('KAFKA_DEBUG', false),
        'brokers' => env('KAFKA_BROKERS', 'localhost:9092'),
        'auto_commit' => 'false',
        'group_id' => 'myConsumerGroup',
        'consumer' => [
            'sasl.username' => env('KAFKA_USERNAME', null),
            'sasl.password' => env('KAFKA_PASSWORD', null),
            'auto.offset.reset' => 'smallest',
            'security.protocol' => env('KAFKA_SECURITY_PROTOCOL', 'SASL_SSL'),
            'sasl.mechanisms' => env('KAFKA_SASL_MECHANISMS', 'SCRAM-SHA-256'),
            'compression.type' => 'gzip',
        ],
        'producer' => [
            'sasl.username' => env('KAFKA_USERNAME', null),
            'sasl.password' => env('KAFKA_PASSWORD', null),
            'security.protocol' => env('KAFKA_SECURITY_PROTOCOL', 'SASL_SSL'),
            'sasl.mechanisms' => env('KAFKA_SASL_MECHANISMS', 'SCRAM-SHA-256'),
            'compression.type' => 'gzip',
            'log_level' => LOG_DEBUG,
            'debug' => 'all'
        ]
    ],

    // ...
],

$app->register(Sadeq\LaravelQueueKafka\KafkaServiceProvider::class);