PHP code example of tritran / sqs-queue-bundle

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

    

tritran / sqs-queue-bundle example snippets


class AppKernel extends Kernel
{
    public function registerBundles()
    {
        return [
            // ...
            new \Aws\Symfony\AwsBundle(),
            new \TriTran\SqsQueueBundle\TriTranSqsQueueBundle(),
        ];
    }

    // ...
}

namespace AclBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use TriTran\SqsQueueBundle\Service\Message;

/**
 * Class DefaultController
 *
 * @package AclBundle\Controller
 */
class DefaultController extends Controller
{
    public function indexAction()
    {
        // ...
        
        $data = [
            'from' => '[email protected]',
            'to' => '[email protected]',
            'subject' => 'Greeting Message',
            'body' => 'Congratulation! You have just received a message which was sent from AWS SQS Queue'
        ];
        $this->get('tritran.sqs_queue.emailpool')
            ->sendMessage((new Message())->setBody(serialize($data)));

        // ...
    }
}

namespace AclBundle\Service\Worker;

use TriTran\SqsQueueBundle\Service\Message;
use TriTran\SqsQueueBundle\Service\Worker\AbstractWorker;

class ReminderWorker extends AbstractWorker
{
    /**
     * @param Message $message
     *
     * @return boolean
     */
    protected function execute(Message $message)
    {
        echo 'The message is: ' . $message->getBody();

        return true;
    }
}