PHP code example of bvdputte / kirby-queue

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

    

bvdputte / kirby-queue example snippets


'bvdputte.kirbyqueue.queues' => [
    'queuename' => function($job) {

        // Get your data
        $foo = $job->get('foo');
        $bar = $job->get('bar');
    
        // Do something with your data, for example: send something to kirbylog
        try {
            kirbylog("test")->log($foo . " " . $bar);
        } catch (Exception $e) {
            // Throw an error to fail a job
            throw new Exception($e->getMessage());
            // or just return false, but setting a message for the user is better.
        }
    
        // No need to return or display anything else!
    }
],

$myQueue = kqQueue("queuename"); // "queuename must be the same as set in the options
$myJob = kqJob([ // Pass the variables needed in the handler
    'foo' => "foo",
    'bar' => "bar"
]);
$myQueue->addJob($myJob);

$tomorrow = new DateTime('tomorrow');
$myJob->setDueDate($tomorrow->getTimestamp());

option("bvdputte.kirbyqueue.roots");

option("bvdputte.kirbyqueue.worker.route");