PHP code example of funddy / worker

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

    

funddy / worker example snippets




unddy\Worker\WorkerRedisClient\PredisWorkerRedisClient;
use Funddy\Worker\WorkQueue\RedisWorkQueue;
use Predis\Client;

$predisClient = new Client('tcp://localhost');
$redisClient = new PredisWorkerRedisClient($predisClient);
$queue = new RedisWorkQueue('myqueue', $redisClient);

$queue->publish('Hello world!');



unddy\Worker\WorkerRedisClient\PredisWorkerRedisClient;
use Funddy\Worker\WorkQueue\RedisWorkQueue;
use Predis\Client;

$predisClient = new Client('tcp://localhost');
$redisClient = new PredisWorkerRedisClient($predisClient);
$queue = new RedisWorkQueue('myqueue', $redisClient);

while(true) {
    $message = $queue->consume();//Blocking
    echo $message;
}