PHP code example of bozerkins / php-message-queue

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

    

bozerkins / php-message-queue example snippets


$queue = new \MessageQueue\Queue(
    new \MessageQueue\Environment(
        [
            'dir' => '/var/my-queue-folder',
            'queue' => 'my-queue'
        ]
    )
);

# write two messages
$queue->write(
    [
        'my message', 
        'my second message'
    ]
);

# read two messages
print_r($queue->read(2));

$queue->recycle();

$queue = new \MessageQueue\Queue(
    new \MessageQueue\Environment(
        [
            'dir' => '/var/my-queue-folder',
            'queue' => 'my-queue',
            'rotate_amount' => 200
        ]
    )
);