A simple AWS SQS Messages with PHP
Felicio is a simple library to manipulate AWS SQS Messages.
- Simple;
- Configurable;
- Testable;
- Open source.
Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications.
Install Composer if you don't have it.
composer require geekcom/felicio
Or in your file'composer.json' add:
{
"require": {
"geekcom/felicio": "^2.5.0"
}
}
And the just run:
composer install
and thats it.
Rename .felicio.example
to .felicio
and fill in the correct information about your AWS SQS account.
AWS_SQS_ACCESS_KEY=
AWS_SQS_SECRET_KEY=
AWS_SQS_REGION=
AWS_SQS_API_VERSION=latest
require __DIR__ . '/vendor/autoload.php';
use Felicio\Felicio;
$felicioDotFile = __DIR__ . '/.felicio';
$felicio = new Felicio($felicioDotFile);
$params = [
'QueueUrl' => 'https://sqs.us-west-2.amazonaws.com/999999999/my_queue',
'MessageBody' => 'test message'
];
$felicio->sendMessage($params);
require __DIR__ . '/vendor/autoload.php';
use Felicio\Felicio;
$felicioDotFile = __DIR__ . '/.felicio';
$felicio = new Felicio($felicioDotFile);
$params = [
'AttributeNames' => ['SentTimestamp'],
'MaxNumberOfMessages' => 1,
'MessageAttributeNames' => ['All'],
'QueueUrl' => 'https://sqs.us-west-2.amazonaws.com/999999999/my_queue',
'WaitTimeSeconds' => 0,
];
$message = $felicio->receiveMessage($params);
var_dump($message);
require __DIR__ . '/vendor/autoload.php';
use Felicio\Felicio;
$felicioDotFile = __DIR__ . '/.felicio';
$felicio = new Felicio($felicioDotFile);
$params = [
'QueueUrl' => 'https://sqs.us-west-2.amazonaws.com/999999999/my_queue',
'ReceiptHandle' => '', // required
];
$felicio->deleteMessage($params);
require __DIR__ . '/vendor/autoload.php';
use Felicio\Felicio;
$felicioDotFile = __DIR__ . '/.felicio';
$felicio = new Felicio($felicioDotFile);
$queueUrl = 'https://sqs.us-west-2.amazonaws.com/999999999/my_queue';
$messages = $felicio->countMessages($queueUrl);
var_dump($messages);
Feel free to contribute, make a fork!
The Felicio library is open-source software licensed under the MIT license.
Open a new Issue or look for a closed issue
- Daniel Rodrigues (@geekcom)