Giter Club home page Giter Club logo

felicio's Introduction

Felicio

A simple AWS SQS Messages with PHP

Scrutinizer Code Quality Latest Stable Version Minimum PHP Version License

About Felicio and SQS

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.

Installation

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.


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

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

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

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

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.

Open a new Issue or look for a closed issue

Author

felicio's People

Contributors

geekcom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.