PHPackages                             uzmak/yii2-kafka-7-4 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. uzmak/yii2-kafka-7-4

ActiveLibrary[Queues &amp; Workers](/categories/queues)

uzmak/yii2-kafka-7-4
====================

Reusable Yii2 Kafka worker package with PHP 7.4+ support

v2.0.0(1mo ago)06MITPHPPHP &gt;=7.4

Since Apr 9Pushed 1mo agoCompare

[ Source](https://github.com/Muxtorov98/yii2-kafka-7.4)[ Packagist](https://packagist.org/packages/uzmak/yii2-kafka-7-4)[ RSS](/packages/uzmak-yii2-kafka-7-4/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

yii2-kafka-7.4
==============

[](#yii2-kafka-74)

Reusable Yii2 Kafka worker and publisher package for PHP 7.4+.

Install
-------

[](#install)

```
composer require uzmak/yii2-kafka-7-4
```

For local path repository:

```
{
  "repositories": [
    {
      "type": "path",
      "url": "../Composer-package/yii2-kafka-7.4"
    }
  ]
}
```

Requirements
------------

[](#requirements)

- PHP 7.4+
- ext-rdkafka
- Yii2

App Config
----------

[](#app-config)

```
'components' => [
    'kafka' => [
        'class' => Uzmak\Yii2Kafka74\KafkaConfigProvider::class,
        'brokers' => '127.0.0.1:9092',
        'username' => 'username',
        'password' => 'secret',
        'securityProtocol' => 'SASL_PLAINTEXT',
        'saslMechanisms' => 'PLAIN',
        'autoOffsetReset' => 'earliest',
        'autoCommit' => true,
        'consumeTimeoutMs' => 1000,
        'retryMaxAttempts' => 3,
        'retryBackoffMs' => 500,
        'producerFlushRetries' => 3,
        'producerFlushTimeoutMs' => 10000,
        'debug' => '',
        'logLevel' => 4,
    ],
],
'controllerMap' => [
    'worker' => [
        'class' => Uzmak\Yii2Kafka74\controllers\WorkerController::class,
        'handlerPath' => '@common/kafka/handlers',
        'handlerNamespace' => 'common\\kafka\\handlers',
    ],
    'kafka-publish' => [
        'class' => Uzmak\Yii2Kafka74\controllers\KafkaPublishController::class,
    ],
],
```

If broker does not require auth:

```
'kafka' => [
    'class' => Uzmak\Yii2Kafka74\KafkaConfigProvider::class,
    'brokers' => 'kafka:9092',
    'username' => null,
    'password' => null,
],
```

Handler Example
---------------

[](#handler-example)

```
