PHPackages                             phpkafka/laravel-kafka - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpkafka/laravel-kafka

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpkafka/laravel-kafka
======================

laravel-kafka

1.0.x-dev(4y ago)15981MITPHPPHP &gt;=7.1

Since Aug 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/chenpeng78/laravel-kafka)[ Packagist](https://packagist.org/packages/phpkafka/laravel-kafka)[ RSS](/packages/phpkafka-laravel-kafka/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Kafka队列

#### 安装

[](#安装)

1. 安装PHP依赖库

    ```
    pecl install rdkafka
    ```
2. 在PHP的初始化文件php.ini中添加以下一行语句以开启Kafka扩展。

    ```
    extension=rdkafka.so
    ```

    b. 检车 rdkafka 是否安装成功

    ```
        注意：如果你想在 php-fpm 上运行它，请先重启你的 php-fpm

        php -i | grep rdkafka

    你的输出应该是这样的

        rdkafka
        rdkafka support => enabled
        librdkafka version (runtime) => 1.6.1-38-g7f0929-dirty
        librdkafka version (build) => 1.6.1.255

    ```
3. 通过 Composer 安装这个包

    ```
     composer require phpkafka/laravel-kafka

    ```
4. 将 LaravelQueueKafkaServiceProvider 添加到providers数组中config/app.php

    ```
     phpkafka\LaravelQueueKafka\LaravelQueueKafkaServiceProvider::class,

    ```

    如果您使用 Lumen，请将其放入 bootstrap/app.php

    ```
     $app->register(phpkafka\LaravelQueueKafka\LumenQueueKafkaServiceProvider::class);

    ```

5.要使用 kafka 队列驱动程序，需要在 config/queue.php 配置文件中配置一个 kafka 连接。

```
   'kafka' => [
        'driver' => 'kafka',
        'queue' => env('KAFKA_QUEUE', 'default'),
        'consumer_group_id' => env('KAFKA_CONSUMER_GROUP_ID', 'laravel_queue'),
        'brokers' => env('KAFKA_BROKERS', 'localhost'),
        'sleep_on_error' => env('KAFKA_ERROR_SLEEP', 5),
        'sleep_on_deadlock' => env('KAFKA_DEADLOCK_SLEEP', 2),
   ]

```

6. 将这些属性添加到.env 文件中

    ```
     QUEUE_CONNECTION=kafka

     选择配置
     KAFKA_BROKERS=127.0.0.1:9092 #kafka地址，多个用,隔开
     KAFKA_ERROR_SLEEP=5 #确定的秒数睡眠与kafka交流如果有一个错误(秒)
     KAFKA_DEADLOCK_SLEEP=2 #睡眠时检测到死锁(秒)
     KAFKA_QUEUE=default #默认队列名
     KAFKA_CONSUMER_GROUP_ID=test  #默认分组

    ```
7. 如果你想为特定的消费者Group运行队列

    ```
     export KAFKA_CONSUMER_GROUP_ID="testgroup" && php artisan queue:work --sleep=3 --tries=3

    ```
8. 多消费者 1629095586676.jpg[![1629095586676](https://user-images.githubusercontent.com/9024302/129521025-59821ce5-2d4b-43f1-871c-88dc9f207cee.jpg)](https://user-images.githubusercontent.com/9024302/129521025-59821ce5-2d4b-43f1-871c-88dc9f207cee.jpg)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1790d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9024302?v=4)[chenpeng](/maintainers/chenpeng78)[@chenpeng78](https://github.com/chenpeng78)

---

Top Contributors

[![chenpeng78](https://avatars.githubusercontent.com/u/9024302?v=4)](https://github.com/chenpeng78 "chenpeng78 (6 commits)")

### Embed Badge

![Health badge](/badges/phpkafka-laravel-kafka/health.svg)

```
[![Health](https://phpackages.com/badges/phpkafka-laravel-kafka/health.svg)](https://phpackages.com/packages/phpkafka-laravel-kafka)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M209](/packages/illuminate-broadcasting)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

58171.9k14](/packages/api-platform-laravel)[rapidez/core

Rapidez Core

1823.5k72](/packages/rapidez-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
