PHP code example of buzzingpixel / corbomite-queue

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

    

buzzingpixel / corbomite-queue example snippets



declare(strict_types=1);

use corbomite\di\Di;
use corbomite\queue\QueueApi;

/** @noinspection PhpUnhandledExceptionInspection */
$queueApi = Di::diContainer()->get(QueueApi::class);

$batchModel = $queueApi->makeActionQueueBatchModel([
    'name' => 'this_is_a_test',
    'title' => 'This is a Test',
    'items' => [
        $queueApi->makeActionQueueItemModel([
            'class' => \some\ClassThing::class,
        ]),
        $queueApi->makeActionQueueItemModel([
            'class' => \another\ClassThing::class,
        ]),
        $queueApi->makeActionQueueItemModel([
            'class' => \more\Classes::class,
            'method' => 'someMethod', // If method is not specified, --invoke is assumed
            // Provide anything you want in this array, your method will receive it as an argument
            'context' => [
                'stuff' => 'thing',
            ],
        ]),
    ],
]);

/** @noinspection PhpUnhandledExceptionInspection */
$queueApi->addToQueue($batchModel);
bash
php app queue/create-migrations
bash
php app migrate/up
bash
php app queue/run