PHP code example of wandu / q

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

    

wandu / q example snippets


use Wandu\Q\Adapter\SqsAdapter;
use Wandu\Q\Queue;
use Wandu\Q\Serializer\JsonSerializer;

$sender = new Queue(new JsonSerializer(), new SqsAdapter(
    'xxxxxxxxxxxx', // key
    'xxxxxxxxxxxx', // secret
    'ap-northeast-1', // region
    'https://sqs.ap-northeast-1.amazonaws.com/000000000000/queue-name' // queue url
));
$sender->enqueue([
    'body' => 'kkk',
    '333' => 'halelleknflaksdf',
]);

use Wandu\Q\Adapter\SqsAdapter;
use Wandu\Q\Queue;
use Wandu\Q\Serializer\JsonSerializer;

$sender = new Queue(new JsonSerializer(), new SqsAdapter(
    'xxxxxxxxxxxx', // key
    'xxxxxxxxxxxx', // secret
    'ap-northeast-1', // region
    'https://sqs.ap-northeast-1.amazonaws.com/000000000000/queue-name' // queue url
));
while (true) {
    $job = $sender->dequeue();
    if ($job) {
        print_r($job->read());
        $job->delete();
    }
    sleep(3);
}