Package Data | |
---|---|
Maintainer Username: | petermein |
Maintainer Contact: | petermein@gmail.com (Peter Mein) |
Package Create Date: | 2017-08-03 |
Package Last Update: | 2023-12-15 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:06:44 |
Package Statistics | |
---|---|
Total Downloads: | 12,584 |
Monthly Downloads: | 246 |
Daily Downloads: | 5 |
Total Stars: | 168 |
Total Watchers: | 8 |
Total Forks: | 57 |
Total Open Issues: | 14 |
Install librdkafka c library
$ cd /tmp
$ mkdir librdkafka
$ cd librdkafka
$ git clone https://github.com/edenhill/librdkafka.git .
$ ./configure
$ make
$ make install
Install the php-rdkafka PECL extension
$ pecl install rdkafka
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) => 1.0.0-RC2
librdkafka version (build) => 0.11.4.0
Install this package via composer using:
composer require rapide/laravel-queue-kafka
Add LaravelQueueKafkaServiceProvider to providers
array in config/app.php
:
Rapide\LaravelQueueKafka\LaravelQueueKafkaServiceProvider::class,
If you are using Lumen, put this in bootstrap/app.php
$app->register(Rapide\LaravelQueueKafka\LumenQueueKafkaServiceProvider::class);
Add these properties to .env
with proper values:
QUEUE_DRIVER=kafka
If you want to run a worker for a specific consumer group
export KAFKA_CONSUMER_GROUP_ID="group2" && php artisan queue:work --sleep=3 --tries=3
Explaination of consumergroups can be found in this article http://blog.cloudera.com/blog/2018/05/scalability-of-kafka-messaging-using-consumer-groups/
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: http://laravel.com/docs/queues
Run the tests with:
vendor/bin/phpunit
This library is inspired by laravel-queue-rabbitmq by vyuldashev. And the Kafka implementations by Superbalist be sure to check those out.
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.
Tested on: [5.4, 5.5, 5.6, 5.7]