PHPackages                             sshkolyk/laravel-queue-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. [Queues &amp; Workers](/categories/queues)
4. /
5. sshkolyk/laravel-queue-kafka

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

sshkolyk/laravel-queue-kafka
============================

Kafka driver for Laravel Queue

v2.0.0(2mo ago)02↓100%MITPHPPHP &gt;=8.2

Since Mar 8Pushed 2mo agoCompare

[ Source](https://github.com/sshkolyk/laravel-queue-kafka)[ Packagist](https://packagist.org/packages/sshkolyk/laravel-queue-kafka)[ RSS](/packages/sshkolyk-laravel-queue-kafka/feed)WikiDiscussions master Synced 1mo ago

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

Kafka Queue driver for Laravel 12+ and rdkafka 2.x
==================================================

[](#kafka-queue-driver-for-laravel-12-and-rdkafka-2x)

[![Latest Stable Version](https://camo.githubusercontent.com/59eb22f25a96c128eede5c0da0ad01d74f42175fa1fc399c4cf27ffb06b9e3ac/68747470733a2f2f706f7365722e707567782e6f72672f7261706964652f6c61726176656c2d71756575652d6b61666b612f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/rapide/laravel-queue-kafka)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

#### Installation

[](#installation)

1. Install [librdkafka c library](https://github.com/edenhill/librdkafka)

    ```
    $ cd /tmp
    $ mkdir librdkafka
    $ cd librdkafka
    $ git clone https://github.com/edenhill/librdkafka.git .
    $ ./configure
    $ make
    $ make install
    ```
2. Install the [php-rdkafka](https://github.com/arnaud-lb/php-rdkafka) PECL extension

    ```
    $ pecl install rdkafka
    ```
3. a. Add the following to your php.ini file to enable the php-rdkafka extension `extension=rdkafka.so`

    b. Check if rdkafka is installed
    **Note:** If you want to run this on php-fpm restart your php-fpm first.

    ```
        php -i | grep rdkafka
    ```

    Your output should look something like this

    ```
    rdkafka
    rdkafka support => enabled
    librdkafka version (runtime) => 2.12.1
    librdkafka version (build) => 2.12.1.255

    ```
4. Install this package via composer using:

    ```
        composer require sshkolyk/laravel-queue-kafka
    ```
5. If you are using Lumen, put this in `bootstrap/app.php`:

    ```
        $app->register(Rapide\LaravelQueueKafka\LumenQueueKafkaServiceProvider::class);
    ```
6. You can also publish queue-kafka.php config:

    ```
        php artisan vendor:publish --tag queue-kafka-config
    ```
7. Add these properties to `.env` with proper values:

    ```
     QUEUE_DRIVER=kafka

    ```
8. If you want to run a worker for a specific consumer group

    ```
        export KAFKA_CONSUMER_GROUP_ID="group2" && php artisan queue:work --sleep=3
    ```
9. For run parallel in N partitions invoke N workers with:

    ```
        KAFKA_CONSUMER_PARTITION=0 php artisan queue:work
        KAFKA_CONSUMER_PARTITION=1 php artisan queue:work
        ...
    ```
10. \--tries not working with this driver. Make sure you catch all exceptions and enqueue again in your job if needed in your job
    Queue::later() also not working

#### Usage

[](#usage)

Once you completed the configuration you can use Laravel Queue API. If you used other queue drivers you do not need to change anything else. If you do not know how to use Queue API, please refer to the official Laravel documentation:

#### Supported environment variables

[](#supported-environment-variables)

`KAFKA_QUEUE` - default queue(topic) name

`KAFKA_CONSUMER_GROUP_ID` - kafka consumer group, default = 'laravel\_queue'

`KAFKA_CONSUMER_PARTITION` - kafka partition for consume, default = 0

`KAFKA_PRODUCER_PARTITIONER` - Producer partitioner algorithm, default = 'murmur2\_random'

###### Can be:

[](#can-be)

1. random - random distribution, consistent - CRC32 hash of key (Empty and NULL keys are mapped to single partition),
2. consistent\_random - CRC32 hash of key (Empty and NULL keys are randomly partitioned),
3. murmur2 - Java Producer compatible Murmur2 hash of key (NULL keys are mapped to single partition),
4. murmur2\_random - Java Producer compatible Murmur2 hash of key (NULL keys are randomly partitioned. This is functionally equivalent to the default partitioner in the Java Producer.),
5. fnv1a - FNV-1a hash of key (NULL keys are mapped to single partition),
6. fnv1a\_random - FNV-1a hash of key (NULL keys are randomly partitioned).

`KAFKA_BROKERS` - Comma-separated list of Kafka broker addresses the client will initially connect to, default = localhost:9092

`KAFKA_ERROR_SLEEP` - Determine the number of seconds to sleep if there's an error communicating with kafka or false|null, default = 5

`KAFKA_SASL_ENABLE` - Enable SASL authentication. if false other SASL config does not matter, default = false

`KAFKA_SASL_SECURITY_PROTOCOL` - One of SSL, PLAINTEXT, SASL\_PLAINTEXT, SASL\_SSL, default = SASL\_SSL

`KAFKA_SASL_MECHANISM` - One of PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, default = SCRAM-SHA-512

`KAFKA_SSL_CA_LOCATION` - File or directory path to CA certificate(s) for verifying the broker's key, default empty

`KAFKA_SASL_PLAIN_USERNAME` - no default

`KAFKA_SASL_PLAIN_PASSWORD` - no default

`KAFKA_AUTO_COMMIT` - The property enable.auto.commit is set to true by default, and Kafka commits the current offset back to the Kafka broker at a specified interval, default = true. In most cases you don't need to touch this

`KAFKA_AUTO_RESET` - What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):

1. earliest: automatically reset the offset to the earliest offset
2. latest: automatically reset the offset to the latest offset
3. none: throw exception to the consumer if no previous offset is found for the consumer's group
4. anything else: throw exception to the consumer, default = 'earliest'. If you change this first producer messages may be ignored by consumer

`KAFKA_TIMEOUT_MS` - Timeout in ms for most operations, default = 1000

#### Testing

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

#### Acknowledgement

[](#acknowledgement)

This library is based on [laravel-queue-kafka](https://github.com/rapideinternet/laravel-queue-kafka) by rapideinternet.

#### Contribution

[](#contribution)

You can contribute to this package by discovering bugs and opening issues. Please, add to which version of package you create pull request or issue.

#### Supported versions of Laravel

[](#supported-versions-of-laravel)

Tested on: \[12.0\]

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance94

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/43bcbfd4a3b059d2571009351c9e157004e4821877a8afe88852104f0ea9e9e2?d=identicon)[sshkolyk](/maintainers/sshkolyk)

---

Top Contributors

[![sshkolyk](https://avatars.githubusercontent.com/u/14029239?v=4)](https://github.com/sshkolyk "sshkolyk (41 commits)")[![petermein](https://avatars.githubusercontent.com/u/311652?v=4)](https://github.com/petermein "petermein (32 commits)")[![Sin30](https://avatars.githubusercontent.com/u/4537407?v=4)](https://github.com/Sin30 "Sin30 (6 commits)")[![L3o-pold](https://avatars.githubusercontent.com/u/4710495?v=4)](https://github.com/L3o-pold "L3o-pold (2 commits)")[![joesb](https://avatars.githubusercontent.com/u/518081?v=4)](https://github.com/joesb "joesb (2 commits)")[![ac1982](https://avatars.githubusercontent.com/u/11901124?v=4)](https://github.com/ac1982 "ac1982 (1 commits)")[![innov8go](https://avatars.githubusercontent.com/u/10679869?v=4)](https://github.com/innov8go "innov8go (1 commits)")

---

Tags

laravelqueuekafkardkafka

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[imtigger/laravel-job-status

Laravel Job Status

5272.1M2](/packages/imtigger-laravel-job-status)

PHPackages © 2026

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