PHP code example of leocarmo / php-redis-queue

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

    

leocarmo / php-redis-queue example snippets


use LeoCarmo\RedisQueue\Publisher;

$redis = new Redis();
$redis->connect('localhost');

Publisher::setQueueClient('my-queue', $redis);

Publisher::pushMessage('my-queue', [
    'message' => 'Hello World!'
]);

use LeoCarmo\RedisQueue\Listener;

$redis = new Redis();
$redis->connect('localhost');

Listener::setQueueClient('my-queue', $redis);

Listener::restoreMessagesFromProcessingQueue('my-queue', 1);

while (true) {
    Listener::processMessages('my-queue', 1, 1, function ($events) {
        dump($events);
    });
}