PHP code example of springbot / magento2-queue

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

    

springbot / magento2-queue example snippets




namespace Your\Name\Space;

use Springbot\Queue\Model\Queue;

class QueueExample
{
    private $queue;

    /**
     * QueueExample constructor
     * @param Queue $queue
     */
    public function __construct(Queue $queue)
    {
        $this->queue = $queue;
    }

    /**
     * Queue examples
     */
    public function runQueueExamples()
    {
        // Enqueue a job 
        $this->queue->scheduleJob('\Fully\Qualified\ClassName', 'methodToRun', ['arg1', 'arg2']);
        
        // Process the queue 
        $this->queue->runNextJob();
        
        // Get a collection of current jobs
        $jobs = $this->queue->getCollection();
    }
}
bash
composer nto module:enable Springbot_Queue
bash
 php bin/magento springbot:queue:enqueue <class> <method> [<queue>] [<priority>] [<params>1] ... [<params>N]
bash
 php bin/magento springbot:queue:list
bash
php bin/magento springbot:queue:process