PHP code example of m6web / aws-bundle

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

    

m6web / aws-bundle example snippets


    $client = $this->getContainer()->get('m6web_aws.sqs.workers');
    $queue = $client->getQueue('queue_test');

    for ($i=0; $i<100; $i++) {
        echo $client->sendMessage($queue, "hello world $i") . "\n";
    }

    $i = 0;
    while($messages = $client->receiveMessage($queue, 10)) {
        foreach($messages as $message) {
            echo $message['Body'] . "... ";
            if ($client->deleteMessage($queue, $message['ReceiptHandle'])) {
                echo "OK\n";
                $i++;
            } else echo "ERROR\n";
        }
    }

    echo"\n===> READ : $i\n";

    $client = $this->getContainer()->get('m6web_aws.sts.m6');

    $sessionToken = $client->getSessionToken();
    $credentials  = $client->createCredentials($sessionToken);

    echo "Key : " . $credentials->getSecretKey() . "\n";
    echo "Token : " . $credentials->getSecurityToken() . "\n";