PHP code example of rabbitevents / redis-transport

1. Go to this page and download the library: Download rabbitevents/redis-transport 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/ */

    

rabbitevents / redis-transport example snippets


return [
    'default' => env('RABBITEVENTS_CONNECTION', 'redis'),

    'connections' => [
        'redis' => [
            'driver' => 'redis',
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'port' => env('REDIS_PORT', 6379),
            'password' => env('REDIS_PASSWORD', null),
            'database' => env('REDIS_DB', 0),
            'timeout' => env('REDIS_TIMEOUT', 3.0),
            'stream' => env('RABBITEVENTS_REDIS_STREAM', 'events'),
            'consumer' => env('RABBITEVENTS_REDIS_CONSUMER', gethostname() ?: 'default'),
        ],
        // ...
    ],
];

use App\Events\UserRegistered;

event(new UserRegistered($user));
// or
publish('user.registered', ['user_id' => $user->id]);
bash
php artisan rabbitevents:listen --connection=redis
bash
php artisan rabbitevents:listen user.registered,order.* --connection=redis