PHP code example of redcode / kue

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

    

redcode / kue example snippets


// Connect to redis "localhost:6379"
$kue = Kue::createQueue();

// Connect "redis_server:6379" and select db to "1"
$kue = Kue::createQueue(array('host' => 'redis_server', 'db' => 1));

$kue = Kue::createQueue();

$kue->originalMode(true);

$kue = Kue::createQueue();

$kue->create('email', array(
    'to' => '[email protected]',
    'subject' => 'Reset your password!',
    'body' => 'Your can reset your password in 5 minutes. Url: http://xxx/reset'
))->save();

$kue = Kue::createQueue();

$kue->create('email', array(
    'to' => '[email protected]',
    'subject' => 'Reset your password!',
    'body' => 'Your can reset your password in 5 minutes. Url: http://xxx/reset'
))->priority('high')->save();

$kue = Kue::createQueue();

$kue->create('email', array(
    'to' => '[email protected]',
    'subject' => 'Reset your password!',
    'body' => 'Your can reset your password in 5 minutes. Url: http://xxx/reset'
))->timing('tomorrow')->save();

$kue = Kue::createQueue();

$kue->create('email', array(
    'to' => '[email protected]',
    'subject' => 'Reset your password!',
    'body' => 'Your can reset your password in 5 minutes. Url: http://xxx/reset'
))->delay(3600)->save();

$kue = Kue::createQueue();

$kue->create('email', array(
    'to' => '[email protected]',
    'subject' => 'Reset your password!',
    'body' => 'Your can reset your password in 5 minutes. Url: http://xxx/reset'
))->attempts(5)->save();

$kue = Kue::createQueue();

// Process the `email` type job
$kue->on('process:email', function($job){
    // Process logic
    $data = $job->data
    mail($data['to'], $data['subject'], $data['body']);
});

// Will blocking process to subscribe the queue
$kue->process();

$kue = Kue::createQueue();

// Process the `email` type job
$kue->on('process:email', function($job){
    // Process logic
    $data = $job->data
    mail($data['to'], $data['subject'], $data['body']);
});

// Process `email` type only
$kue->process('email');

$kue = Kue::createQueue();

// Process `email` type only
$kue->process('email', function($job){
   // Process logic
   $data = $job->data
   mail($data['to'], $data['subject'], $data['body']);
});

$kue = Kue::createQueue();

// Process all types
$kue->process(function($job){
   // Process logic
   log($job->type . ' processed');
});