PHP code example of corley / queue

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

    

corley / queue example snippets


$queue = new Queue("queue name", $queueAdapter);

list($receipt, $message) = $queue->receive();

// receive with options
list($receipt, $message) = $queue->receive(["timeout" => 15*60]);

$queue->send("my message");

// send with options
$queue->send("my message", ["delay" => 20]);

$queue->delete($receipt);

// delete with options
$queue->delete($receipt, ["delay" => 20]);

$queue = new Queue("https://sqs.amazon.com/39857/urs", $sqsAdapter);
$queue->send("message", toSQS(["delay" => 20]));

function toSQS(array options = []) {
    $opts = [];
    if (array_key_exists("delay", $options)) {
        $opts["DelaySeconds"] = $options["delay"];
    }
    return $opts;
}

public function send($queueName, $message, array $options);
public function receive($queueName, array $options);
public function delete($queueName, $receipt, array $options);