https://github.com/geekcom/felicio
A simple AWS SQS Messages with PHP
https://github.com/geekcom/felicio
message-queue php queues sqs
Last synced: 8 months ago
JSON representation
A simple AWS SQS Messages with PHP
- Host: GitHub
- URL: https://github.com/geekcom/felicio
- Owner: geekcom
- License: mit
- Created: 2019-08-29T16:58:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T17:19:16.000Z (over 2 years ago)
- Last Synced: 2025-03-18T19:55:10.635Z (8 months ago)
- Topics: message-queue, php, queues, sqs
- Language: PHP
- Homepage:
- Size: 146 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Felicio
_A simple AWS SQS Messages with PHP_
[](https://scrutinizer-ci.com/g/geekcom/felicio/?branch=master)
[](https://packagist.org/packages/geekcom/felicio)
[](https://php.net/)
[](https://packagist.org/packages/geekcom/felicio)
### About Felicio and SQS
Felicio is a simple library to manipulate [AWS SQS Messages](https://aws.amazon.com/pt/sqs/).
- Simple;
- Configurable;
- Testable;
- Open source.
[Amazon Simple Queue Service (SQS)](https://aws.amazon.com/pt/sqs/) is a fully managed message queuing service
that enables you to decouple and scale microservices, distributed systems, and serverless applications.
### Installation
Install [Composer](http://getcomposer.org) if you don't have it.
```
composer require geekcom/felicio
```
Or in your file'composer.json' add:
```json
{
"require": {
"geekcom/felicio": "^2.5.0"
}
}
```
And the just run:
composer install
and thats it.
----------------------------------------------------------------------------------------------------------------------------
### Configure
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
```
### Send a message
```php
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);
```
### Receive a message
```php
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);
```
### Delete a message
```php
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);
```
### Count messages
```php
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);
```
### Contributing
Feel free to contribute, make a fork!
### License
The Felicio library is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).
### [Questions?](https://github.com/felicio/issues)
Open a new [Issue](https://github.com/felicio/issues) or look for a closed issue
### Author
- Daniel Rodrigues ([@geekcom](http://github.com/geekcom))