PHP code example of mariano / disque-php

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

    

mariano / disque-php example snippets


use Disque\Connection\Credentials;
use Disque\Client;

$nodes = [
    new Credentials('127.0.0.1', 7711),
    new Credentials('127.0.0.1', 7712, 'password'),
];

$disque = new Client($nodes);

$job = new \Disque\Queue\Job(['name' => 'Claudia']);
$disque->queue('my_queue')->push($job);

$job = new \Disque\Queue\Job(['name' => 'Mariano']);
$disque->queue('my_queue')->schedule($job, new \DateTime('+2 hours'));

$queue = $disque->queue('my_queue');
while ($job = $queue->pull()) {
    echo "GOT JOB!";
    var_dump($job->getBody());
    $queue->processed($job);
}