PHP code example of afikrim / laravel-redis-stream
1. Go to this page and download the library: Download afikrim/laravel-redis-stream library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Console\Commands;
use Afikrim\LaravelRedisStream\Console\ConsumeCommand as ConsoleConsumeCommand;
class ConsumeCommand extends ConsoleConsumeCommand
{
/**
* Function to listen to new event stream
*/
protected function listen()
{
$options = [];
if ($this->hasOption('group')) {
$options['group'] = $this->option('group');
}
if ($this->hasOption('consumer')) {
$options['consumer'] = $this->option('consumer');
}
if ($this->hasOption('count')) {
$options['count'] = $this->option('count');
}
if ($this->hasOption('block')) {
$options['block'] = $this->option('block');
}
if ($this->laravel->config->get('redis.stream.prefix')) {
$options['prefix'] = $this->laravel->config->get('redis.stream.prefix');
}
$server = new TransporterServer($options);
$server->addHandler('mystream', function ($result) {return $result;});
$server->addHandler('mystream2', function ($result) {return $result;});
// And another awesome handlers...
$server->listen();
}
}
protected $commands = [
// you other command,
\App\Console\Commands\ConsumeCommad::class
]