Clients overview

AsyncAws has implemented the most popular API clients. On this page you find some installation instructions and a complete list of clients.

Install and configure

You install a client with Composer. Here is an example to install DynamoDb:

composer require async-aws/dynamo-db

To instantiate a DynamoDb client (or any other client) you could provide four arguments. All arguments are optional and sensible defaults are used.

use AsyncAws\Core\Configuration; use AsyncAws\Core\Credentials\ConfigurationProvider; use AsyncAws\Core\HttpClient\AwsHttpClientFactory; use AsyncAws\DynamoDb\DynamoDbClient; $config = Configuration::create([ 'region' => 'eu-central-1', ]); $credentialProvider = new ConfigurationProvider(); $httpClient = HttpClient::create(); // ... Instance of Symfony's HttpClientInterface // Or, to enable automatic retries on top of your own HttpClient // $httpClient = AwsHttpClientFactory::createRetryableClient($httpClient); T $logger = // ... A PSR-3 logger $dynamoDb = new DynamoDbClient($config, $credentialProvider, $httpClient, $logger);

A common way to instantiate a DynamoDb client might look like:

use AsyncAws\DynamoDb\DynamoDbClient; $dynamoDb = new DynamoDbClient([ 'region' => 'eu-central-1', 'accessKeyId' => 'AKIAIOSFODNN7EXAMPLE', 'accessKeySecret' => 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', ]);

See section about authentication to learn more about different ways to authenticate.

Dependency injection container

If your application is using a dependency injection container, you may configure a client like:

Symfony

services: AsyncAws\DynamoDb\DynamoDbClient: arguments: - region: "eu-central-1" accessKeyId: "AKIAIOSFODNN7EXAMPLE" accessKeySecret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" - ~ # Use the default authentication providers - "@http_client" - "@logger"

If you are using Symfony you may ease configuration by install the Symfony Bundle.

Laravel

use Illuminate\Support\ServiceProvider; use AsyncAws\DynamoDb\DynamoDbClient; class AsyncAwsProvider extends ServiceProvider { public function register() { $this->app->bind( DynamoDbClient::class, function($app) { return new DynamoDbClient([ 'region' => 'eu-central-1', 'accessKeyId' => 'AKIAIOSFODNN7EXAMPLE', 'accessKeySecret' => 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', ]); } ); } }

Client factory

If you don't use dependency injection, you might be interested in the AwsClientFactory that can be used to instantiate API clients.

use AsyncAws\Core\AwsClientFactory; $factory = new AwsClientFactory([ 'region' => 'eu-central-1', 'accessKeyId' => 'AKIAIOSFODNN7EXAMPLE', 'accessKeySecret' => 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', ]); $dynamoDb = $factory->dynamoDb(); $sqs = $factory->sqs();

Use

Every API client has functions that represent "operations" or API calls. Every such function takes an Input object (or array) as parameter and will return a Result. See the API client's class to learn what operations are supported and what the input and output are.

All Input objects for SQS is located in AsyncAws\Sqs\Input\* and all Result objects are located in AsyncAws\Sqs\Result\*.

Your IDE will also be helpful to discover function and how to use them. See example from PHPStorm:

PHPStorm function help

All supported clients

Here is a list of supported clients. If there is a need for another client or a new operation, it can be automatically generated. See the contribution guide for more information.

Api Client Package name
AppSync async-aws/app-sync
Athena async-aws/athena
CloudFormation async-aws/cloud-formation
CloudFront async-aws/cloud-front
CloudWatch async-aws/cloud-watch
CloudWatchLogs async-aws/cloud-watch-logs
CodeBuild async-aws/code-build
CodeCommit async-aws/code-commit
CodeDeploy async-aws/code-deploy
CognitoIdentityProvider async-aws/cognito-identity-provider
Comprehend async-aws/comprehend
DynamoDb async-aws/dynamo-db
ECR async-aws/ecr
ElastiCache async-aws/elasti-cach
EventBridge async-aws/event-bridge
Firehose async-aws/event-bridge
IAM async-aws/iam
Iot async-aws/iot
IotData async-aws/iot-data
Kinesis async-aws/kinesis
KMS async-aws/kms
Lambda async-aws/lambda
LocationService async-aws/location-service
MediaConvert async-aws/media-convert
RdsDataService async-aws/rds-data-service
Rekognition async-aws/rekognition
Route53 async-aws/route53
S3 async-aws/s3
Scheduler async-aws/scheduler
SecretsManager async-aws/secrets-manager
SES async-aws/ses
SNS async-aws/sns
SQS async-aws/sqs
SSM async-aws/ssm
SSO async-aws/sso
STS async-aws/core
StepFunctions async-aws/step-functions
TimestreamQuery async-aws/timestream-query
TimestreamWrite async-aws/timestream-write
Translate async-aws/translate
XRay async-aws/x-ray