PHP code example of rumd3x / php-queues

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

    

rumd3x / php-queues example snippets


use Rumd3x\Queues\Queue;
$queue = new Queue(Queue::ACTION_RUN_FILE);
$queue->setAction('/var/www/test.php')->pushTo('example_queue');

use Rumd3x\Queues\Queue;
$queue = new Queue(Queue::ACTION_RUN_STATIC);
$queue->setAction("\\App\\Synchronizer")->pushTo('sync');
// This is equal to calling \App\Synchronizer::run();

use Rumd3x\Queues\Queue;
$queue = new Queue(Queue::ACTION_RUN_INSTANCE);
$queue->setAction("\\App\\Synchronizer")->pushTo('sync');
// This is equal to doing 
// $sync = new \App\Synchronizer;
// $sync->run();

use Rumd3x\Queues\QueueManager;
$manager = QueueManager::getInstance();
while (true) {
    $manager->runAll();
}

use Rumd3x\Queues\QueueManager;
$manager = QueueManager::getInstance();
while (true) {
    $manager->run('example_queue');
}

use Rumd3x\Queues\QueueManager;
use Rumd3x\Queues\Queue;

$manager = QueueManager::getInstance();

$queue = new Queue(Queue::ACTION_RUN_FILE);
$queue->setAction('/var/www/test.php');

$manager->isQueued($queue); // returns true or false
$manager->isRunning($queue); // returns true or false
$manager->isQueueFree('sync'); // returns true or false