1. Go to this page and download the library: Download mahmud/buffered-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/ */
mahmud / buffered-queue example snippets
use Mahmud\BufferedQueue\BufferedQueue;
// Maximum size is 3
$queue = BufferedQueue::make('key', function($items){
var_dump($items); // Output is mentioned below
}, 3);
$queue->push('item 1');
$queue->push('item 2');
$queue->push('item 3');
$queue->push('item 4');
$queue->push('item 5');
$queue->push('item 6');
$queue->push('item 7');
$queue->finish();
// Output
// First
[
'item 1', 'item 2', 'item 3'
]
// Second
[
'item 4', 'item 5', 'item 6'
]
// Third
[
'item 7'
]
use Mahmud\BufferedQueue\HandlerContract;
class QueueHandler implements HandlerContract {
public function handle($items) {
// Do something
}
}
$queue = BufferedQueue::make('key', new QueueHandler, 3);