Download the PHP package ensi/laravel-phprdkafka-consumer without Composer
On this page you can find all versions of the php package ensi/laravel-phprdkafka-consumer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ensi/laravel-phprdkafka-consumer
More information about ensi/laravel-phprdkafka-consumer
Files in ensi/laravel-phprdkafka-consumer
Package laravel-phprdkafka-consumer
Short Description Opiniated High Level consumer for laravel-phprdkafka
License MIT
Informations about the package laravel-phprdkafka-consumer
Laravel PHP Rdkafka Consumer
Opiniated High Level consumer for ensi/laravel-phprdkafka
Installation
Firstly, you have to install and configure ensi/laravel-phprdkafka
Then,
Publish the config file with:
Now go to config/kafka-consumer.php
and add processors there.
Version Compatibility
Laravel rdkakfa-consumer | Laravel | PHP | ensi/laravel-phprdkafka |
---|---|---|---|
^0.1.0 | ^7.x || ^8.x | ^8.0 | ^0.1.4 |
^0.2.0 | ^7.x || ^8.x | ^8.0 | ^0.1.4 |
^0.2.1 | ^7.x || ^8.x | ^8.0 | ^0.2 |
^0.2.5 | ^8.x || ^9.x | ^8.0 | ^0.2 |
^0.3.0 | ^8.x || ^9.x | ^8.0 | ^0.3 |
^0.3.2 | ^8.x || ^9.x || ^10.x | ^8.0 | ^0.3 |
^1.0.0 | ^8.x || ^9.x | ^8.0 | ^0.3 |
^2.0.0 | ^10.x || ^11.x | ^8.1 | ^0.3 |
^2.0.1 | ^10.x || ^11.x | ^8.1 | ^0.4.0 |
Basic Usage
The package provides php artisan kafka:consume {topic} {consumer=default} {--max-events=0} {--max-time=0} {--once}
command that executes the first processor that matches given topic and consumer name. Consumer name is taken from ensi/laravel-phprdkafka config
file.
Processors in config have the following configuration options:
Important! Some topics have to have different consumer settings, such as start reading topic from the beginning or don't create topic if it is not exists yet.
For such cases you need to configure several consumers and use suitable one.
Synchronous processors
Most of the time all tou need is a synchronous processor. A simple example of such processor:
Queueable processors
If you want to stream message to Laravel's own queue you can use spatie/laravel-queueable-action
If for some reason you don't want to rely on that package you can swich to Laravel Jobs
In both cases you also need to specify 'queue' => true
or 'queue' => 'my-favorite-queue'
in the package's config for a given processor.
Processor using Laravel Job example:
Handling signals
php artisan kafka:consume ...
command can be configured to gracefully stop after receiving some OS signals.
Such signals can be set in the stop_signals
key of the package config, e.g 'stop_signals' => [SIGINT, SIGQUIT]
.
You can use any of the constants defined by the pcntl extension https://www.php.net/manual/en/pcntl.constants.php
Contributing
Please see CONTRIBUTING for details.
Consumer faking
Testing tools have been added to test the developed handlers. You can create a fake Consumer and call the topic listening command:
Testing
Testing
- composer install
- composer test
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-phprdkafka-consumer with dependencies
ext-rdkafka Version *
ensi/laravel-phprdkafka Version ^0.4.0
laravel/framework Version ^10.0 || ^11.0