PHP code example of dcarbone / ugly-queue

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

    

dcarbone / ugly-queue example snippets


$queueBaseDir = 'path to where you would like queue files and directories to be stored';

$manager = new UglyQueueManager($queueBaseDir);

$sandwichQueue = $manager->createQueue('sandwiches');

$sandwichQueue->lock();

$sandwichQueue->addItems(array(
    'bread',
    'meat',
    'cheese',
    'lettuce',
    'bread'
));

$sandwichQueue->unlock();

$queueBaseDir = 'path to where you would like queue files and directories to be stored';

$manager = new UglyQueueManager($queueBaseDir);

$tastySandwich = $manager->getQueue('sandwiches');

// 'sandwiches' queue will exist now

$tastySandwich->lock();

// Specify the number of items you wish to retrieve from the queue

$items = $tastySandwich->retrieveItems(4);

// $items is now an array...

var_export($items);

/*
array (
  4 => 'bread',
  3 => 'lettuce',
  2 => 'cheese',
  1 => 'meat',
)
*/