GithubHelp home page GithubHelp logo

gromnan / async-aws Goto Github PK

View Code? Open in Web Editor NEW

This project forked from async-aws/aws

1.0 2.0 0.0 6.39 MB

AWS SDK with readable code and async responses

License: MIT License

PHP 99.68% Makefile 0.24% JavaScript 0.01% Shell 0.08%

async-aws's Introduction

Async AWS client

If you are one of those people that like the Amazon PHP SDK but hate the fact that you need to download Guzzle, PSR-7 and every AWS API client to use it?

This is the library for you!

What is new?

The official AWS PHP SDK is great. It is feature complete, it supports all Amazon APIs and is maintained by some really talented developers. This library is different. It is maintained by some dumb and lazy people.

The goals of this client are:

  1. Async first. Everything is asynchronous and responses are only downloaded if needed.
  2. Not feature complete. We are only covering the handful of services that are used by most people. We are not even covering all of those popular services.
  3. No frequent updates. Updates are great, but if changes are released multiple times every week you cannot keep up-to-date with the changelog. That is especially annoying when the changes are not related to services you use.
  4. Readable code. One should be able to read the code and follow the logic.

and much more...

Installation and usage

All APIs are located in different packages. To install SQS run

composer require async-aws/sqs
use AsyncAws\Sqs\SqsClient;
use AsyncAws\Sqs\Input\SendMessageRequest;

$sqsClient = new SqsClient([
    'region' => 'eu-central-1',
    'accessKeyId' => 'foo',
    'accessKeySecret' => 'bar',
]);

// Call a client's method with an array
$result = $sqsClient->createQueue(['QueueName' => 'bar']);
// Make sure the request is sent
$result->resolve();


// You can also call a client's method with an input object
$input = new SendMessageRequest();
$input
    ->setQueueUrl('https://foo.com/bar')
    ->setMessageBody('foobar');

$result = $sqsClient->sendMessage($input);

// Request is automatically sent when reading the response
echo $result->getMessageId();

How is it async first?

The secret ingredient in creating asynchronous first is not implemented in this library. It actually comes from the Symfony HTTP client. They have implemented all the cool async features that this AWS library just take advantage of.

So what is this library really doing?

Except for being a wrapper around Symfony's HTTP client and make sure we use the async features properly, we also handle authentication, exceptions and provide some response objects.

Pagination

Some API Results are lists of items, like the result of S3Client::listObjectsV2(). These results implement \IteratorAggregate and will automatically use AWS's pagination API to make a new request to fetch the remaining resources in the list.

use AsyncAws\S3\S3Client;
use AsyncAws\S3\Result\AwsObject;
use AsyncAws\S3\Result\CommonPrefix;

$s3Client = new S3Client();
$result = $s3Client->listObjectsV2(['Bucket' => 'foo']);

/** @var AwsObject|CommonPrefix $file */
foreach($result as $file) {
    if ($file instanceof AwsObject) {
        echo $file->getKey();
    }
}

Waiter

Similar to Official AWS PHP SDK, AsyncAws provides waiters to let you wait until an long operation finished.

// create a queue Async and don't wait for the response.
$sqsClient->createQueue(['QueueName' => 'fooBar']);

$waiter = $sqsClient->queueExists(['QueueName' => 'fooBar']);
echo $waiter->isSuccess(); // false
$waiter->wait();
echo $waiter->isSuccess(); // true

more information about waiters and hasers...

Packages overview

Package name Badges BC check
async-aws/core Latest Stable Version Total Downloads
async-aws/cloud-formation Latest Stable Version Total Downloads
async-aws/lambda Latest Stable Version Total Downloads
async-aws/s3 Latest Stable Version Total Downloads
async-aws/ses Latest Stable Version Total Downloads
async-aws/sns Latest Stable Version Total Downloads
async-aws/sqs Latest Stable Version Total Downloads
async-aws/flysystem-s3 Latest Stable Version Total Downloads
async-aws/async-aws-bundle Latest Stable Version Total Downloads

async-aws's People

Contributors

github-actions[bot] avatar jderusse avatar nicolas-grekas avatar nyholm avatar swiffer avatar

Stargazers

 avatar

Watchers

 avatar  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.