lelivrescolaire / sqs-bundle
Communicate with an SQS queue from inside your symfony 2 application.
Installs: 9 597
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 17
Forks: 4
Open Issues: 3
Requires
- php: >=5.3.0
- lelivrescolaire/aws-bundle: dev-master
Requires (Dev)
- atoum/atoum: dev-master
- m6web/coke: ~1.0
- m6web/symfony2-coding-standard: ~1.1
- symfony/config: ~2.5
- symfony/dependency-injection: ~2.5
- symfony/expression-language: ~2.5
- symfony/http-kernel: ~2.5
- symfony/yaml: ~2.5
This package is not auto-updated.
Last update: 2024-12-21 16:36:14 UTC
README
SQS Bundle
Communicate with an SQS queue from inside your symfony 2 application.
This bundle is an extension of lelivrescolaire/AWSBundle.
Installation
$ composer require "lelivrescolaire/sqs-bundle:dev-master"
AppKernel:
public function registerBundles() { $bundles = array( new LLS\Bundle\AWSBundle\LLSAWSBundle(), new LLS\Bundle\SQSBundle\LLSSQSBundle(), ); }
Configuration reference
llsaws: identities: my_identity: # Arbitrary Identity service name type: user # Identity type name (factory alias) fields: # Identity fields key: '<user AWS key>' secret: '<user AWS secret>' region: '<region of the SQS queue>' endpoint: '<endpoint to plug elasticMQ or other third services; not required>' services: my_sqs_service: # Arbitrary service name type: sqs # Service Type (factory alias) identity: my_identity llssqs: queues: my_queue: # Arbitrary Queue service name service: my_sqs_service # SQS Service name name: myQueue # AWS Queue name
Usage
Given the previous config:
<?php namespace Acme\Bundle\MyBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use LLS\Bundle\SQSBundle\Model\Queue; use LLS\Bundle\SQSBundle\Model\Message; class MyController extends Controller { public function myAction() { $identityAsService = $this->get('llsaws.identities.my_identity'); $sqsAsService = $this->get('llsaws.services.my_sqs_service'); $queueAsService = $this->get('llssqs.queues.my_queue'); // Create a queue $queue = $sqsAsService->getQueue('myCreatedQueue'); // Instanciate Queue $sqsAsService->createQueue($queue); // Remotely create the queue var_dump($queue->getUrl()); // Get queue URL // Send a message to a queue $message = new Message(); $message->setBody('Hello world!'); $queueAsService->sendMessage($message); // Fetch messages from a queue $maxMsg = 10; // Max number of messages to fetch $messages = $queueAsService->fetchMessages($maxMsg); foreach ($messages as $message) { var_dump($message->getBody()); $queueAsService->delete($message); // Delete message (only works for fetched Messages) } } }
Ship Monolog logs to SQS
See here.
Contribution
Feel free to send us Pull Requests and Issues with your fixs and features.
Run test
Unit tests
$ ./bin/atoum
Coding standards
$ ./bin/coke