AWS SDK for PHP version 2.5.
Contents AWS SDK for PHP Signing Up for AWS Creating an AWS account 1 1 1 To sign up for AWS 1 To view your AWS credentials 1 Getting your AWS credentials Requirements 1 2 Minimum requirements 2 Optimal settings 2 Compatibility test 2 Installation 2 Installing via Composer 2 Installing via Phar 3 Installing via Zip 4 Installing via PEAR Getting Started Guide 4 4 Including the SDK 4 Creating a client object 5 Factory method 5 Service builder 6 Performing service operations 6
Iterators Comparing Code Samples from Both SDKs Example 1 - Amazon S3 ListParts Operation 12 12 12 From Version 1 of the SDK 12 From Version 2 of the SDK 13 Example 2 - Amazon DynamoDB Scan Operation 13 From Version 1 of the SDK 13 From Version 2 of the SDK 15 Side-by-side Guide Installing and Including the SDKs 15 15 Using Composer 15 Without Composer 16 Configuring and Instantiating the SDKs 16 Instantiating Clients via the Service Builder 16 Instantiating Clients via Client Factorie
A peek under the hood 29 Using command objects 30 Manipulating command objects before execution 30 Request and response objects 30 Managing command state 30 Using requests and responses 31 Executing commands in parallel Error handling with parallel commands Waiters 31 32 32 Introduction 32 Basic Configuration 32 Waiter Objects 33 Waiter Events 33 Custom Waiters 33 Waiter Definitions 34 Iterators 35 Introduction 35 Iterator Objects 36 Basic Configuration 36 Iterator Events
Turn off parameter validation 44 Cache instance profile credentials 45 Check if you are being throttled 45 Preload frequently included files 45 Profile your code to find performance bottlenecks 46 Comparing SDK1 and SDK2 46 Comparing batch requests 46 Frequently Asked Questions (FAQ) 46 What methods are available on a client? 46 What do I do about a cURL SSL certificate error? 46 How do I disable SSL? 47 How can I make the SDK faster? 47 Why can't I upload or download files greater t
Factory method 58 Service builder 59 API Reference AWS CloudTrail Creating a client 59 59 59 Factory method 59 Service builder 60 Blog articles 60 API Reference 60 Amazon CloudWatch 60 Creating a client 61 Factory method 61 Service builder 61 API Reference 61 AWS Data Pipeline 62 Creating a client 62 Factory method 62 Service builder 62 API Reference 63 AWS Direct Connect 63 Creating a client 63 Factory method 63 Service builder 63 API Reference 64 Amazon DynamoDB
API Reference Amazon DynamoDB (2011-12-05) Creating a client 73 73 73 Factory method 73 Service builder 74 Creating tables 74 Updating a table 74 Describing a table 75 Listing tables 75 Iterating over all tables 75 Adding items 76 Retrieving items 76 Query and scan 77 Query 77 Scan 78 Deleting a table 78 Using the WriteRequestBatch 78 API Reference 79 Amazon Elastic Compute Cloud Creating a client 79 79 Factory method 79 Service builder 80 API Reference 80 Amazon Elas
API Reference Amazon Elastic MapReduce Creating a client 87 88 88 Factory method 88 Service builder 88 API Reference Amazon Glacier Creating a client 89 89 89 Factory method 89 Service builder 89 API Reference AWS Identity and Access Management Creating a client 90 90 90 Factory method 90 Service builder 91 API Reference 91 AWS Import/Export 92 Creating a client 92 Factory method 92 Service builder 93 API Reference Amazon Kinesis Creating a client 93 93 93 Factory method 93 S
Creating snapshots 99 Events 99 API Reference Amazon Route 53 Creating a client 100 100 101 Factory method 101 Service builder 101 API Reference Amazon Simple Storage Service Creating a client 101 102 102 Factory method 102 Service builder 102 Creating a bucket 102 Creating a bucket in another region 102 Waiting until the bucket exists 103 Uploading objects 103 Uploading a file 103 Uploading from a stream 104 Listing your buckets 104 Listing objects in your buckets 105 Downlo
Factory method 113 Service builder 114 Creating domains 114 List all domains 114 Retrieving a domain 114 Adding items 114 Retrieving items 115 GetAttributes 115 Select 115 Deleting items 116 Deleting domains 116 API Reference 116 Amazon Simple Notification Service Creating a client 116 116 Factory method 116 Service builder 117 API Reference Amazon Simple Queue Service Creating a client 117 118 118 Factory method 118 Service builder 118 Creating a queue 118 Sending mess
Amazon Simple Workflow Service Creating a client 125 125 Factory method 125 Service builder 126 API Reference DynamoDB Session Handler 126 127 Introduction 127 Basic Usage 127 1. Register the handler 127 2. Create a table for storing your sessions 127 3.
AWS SDK for PHP AWS SDK for PHP Signing Up for AWS Important This page is obsolete. Please see About Access Keys. Creating an AWS account Before you begin, you need to create an account. When you sign up for AWS, AWS signs your account up for all services. You are charged only for the services you use. To sign up for AWS 1. Go to http://aws.amazon.com and click Sign Up Now. 2. Follow the on-screen instructions. AWS sends you a confirmation email after the sign-up process is complete.
Requirements Note Important: Your Secret Access Key is a secret, which only you and AWS should know. It is important to keep it confidential to protect your account. Store it securely in a safe place. Never include it in your requests to AWS, and never e-mail it to anyone. Do not share it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your Secret Access Key.
Requirements } } Consider tightening your dependencies to a known version (e.g., 2.5.*). 2. Download and install Composer. curl -sS https://getcomposer.org/installer | php 3. Install your dependencies. php composer.phar install 4. Require Composer's autoloader. Composer prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process. require '/path/to/sdk/vendor/autoload.
Getting Started Guide Installing via Zip Each release of the AWS SDK for PHP (since 2.3.2) ships with a zip file containing all of the classes and dependencies you need to run the SDK in a PSR-0 compatible directory structure.
Getting Started Guide Using Composer require '/path/to/vendor/autoload.php'; Using the Phar require '/path/to/aws.phar'; Using the Zip require '/path/to/aws-autoloader.php'; Using PEAR require 'AWSSDKforPHP/aws.phar'; For the remainder of this guide, we will show examples that use the Composer installation method. If you are using a different installation method, then you can refer to this section and substitute in the proper code.
Getting Started Guide Service builder Another way to instantiate a service client is using the Aws\Common\Aws object (a.k.a the service builder). The Aws object is essentially a service locator, and allows you to specify credentials and configuration settings such that they can be shared across all client instances. Also, every time you fetch a client object from the Aws object, it will be exactly the same instance.
Getting Started Guide Working with modeled responses The result of a performing an operation is what we refer to as a modeled response. Instead of returning the raw XML or JSON data, the SDK will coerce the data into an associative array and normalize some aspects of the data based on its knowledge of the specific service and the underlying response structure. The actual value returned is a Model (Guzzle\Service\Resource\Model) object.
Migration Guide In the following example, the Amazon S3 Client is used to create a bucket. Then the waiter method is used to wait until the bucket exists. // Create a bucket $s3Client->createBucket(array('Bucket' => 'my-bucket')); // Wait until the created bucket is available $s3Client->waitUntilBucketExists(array('Bucket' => 'my-bucket')); To learn more about how to use and configure waiters, please read the detailed guide to Waiters.
Migration Guide • PHP 5.
Migration Guide The SDK adopts the PSR standards produced by the PHP Framework Interop Group. An immediately noticeable change is that all method names are now named using lower camel-case (e.g., putObject instead of put_object). Required Regions The region must be provided to instantiate a client (except in the case where the service has a single endpoint like Amazon CloudFront). The AWS region you select may affect both your performance and costs.
Migration Guide // New SDK - PutObject operation $result = $s3->putObject(array( 'Bucket' => 'bucket-name', 'Key' => 'object-key.txt', 'Body' => 'lorem ipsum' )); In the new SDK, the putObject() method doesn't actually exist as a method on the client. It is implemented using the __call() magic method of the client and acts as a shortcut to instantiate a command, execute the command, and retrieve the result. A Command object encapsulates the request and response of the call to AWS.
Migration Guide Instead of relying on the CFResponse::isOK() method of the previous SDK to determine if an operation is successful, the new SDK throws exceptions when the operation is not successful. Therefore, you can assume success if there was no exception thrown, but you will need to add try...catch logic to your application code in order to handle potential errors.
Migration Guide $s3 = new AmazonS3(); $response = $s3->list_parts('my-bucket-name', 'my-object-key', 'my-upload-id', array( 'max-parts' => 10 )); if ($response->isOK()) { // Loop through and display the part numbers foreach ($response->body->Part as $part) { echo "{$part->PartNumber}\n"; } } else { echo "Error during S3 ListParts operation.\n"; } From Version 2 of the SDK
Migration Guide $people = array(); // Perform as many Scan operations as needed to acquire all the names of people // that are 16 or older do { // Setup the parameters for the DynamoDB Scan operation $params = array( 'TableName' => 'people', 'AttributesToGet' => array('id', 'age', 'name'), 'ScanFilter' => array( 'age' => array( 'ComparisonOperator' => AmazonDynamoDB::CONDITION_GREATER_THAN_OR_EQUAL, 'AttributeValueList' => array( array(AmazonDynamoDB::TYPE_NUMBER => '16') ) ), ) ); // Add the exclusive sta
Side-by-side Guide print_r($people); From Version 2 of the SDK
Side-by-side Guide 1. Add both of the SDKs as dependencies in your project's composer.json file. { "require": { "aws/aws-sdk-php": "*", "amazonwebservices/aws-sdk-for-php": "*" } } Note: Consider tightening your dependencies to a known version when deploying mission critical applications (e.g., 2.0.*). 2. Download and install Composer. curl -s "http://getcomposer.org/installer" | php 3. Install your dependencies. php composer.phar install 4. Require Composer's autoloader.
Side-by-side Guide This will automatically set up the service clients from Version 1 of the SDK making them accessible through the service builder by keys such as v1.s3 and v1.cloudformation.
Side-by-side Guide Example 1 - Dual Amazon S3 Clients This example demonstrates using an Amazon S3 client from the AWS SDK for PHP working side-by-side with an Amazon S3 client from the first PHP SDK. get('v1.
Providing Credentials to the SDK 'RangeKeyElement' => array('N' => $date->format('j')) ) ))->getResult()->getPath('Item/flavors/SS'); // Generate the message $today = $date->format('l, F jS'); $message = "It's {$today}, and here are our flavors of the day:\n"; foreach ($flavors as $flavor) { $message .= "- {$flavor}\n"; } $message .= "\nCome visit Mr.
Providing Credentials to the SDK • How many sets of credentials you are using • The type of project you are developing (e.g., application, CLI, library) • How often you rotate your credentials • If you rely on temporary or federated credentials • Your deployment process • Your application framework Regardless of the technique used, it is encouraged that you follow the IAM Best Practices when managing your credentials, including the recommendation to not use your AWS account's root credentials.
Providing Credentials to the SDK The easiest way to add a cache to your IAM role credentials is to specify a credentials cache using the credentials.cache option in a client's factory method or in a service builder configuration file. The credentials.cache configuration setting should be set to an object that implements Guzzle's Guzzle\Cache\CacheAdapterInterface (see Guzzle cache adapters).
Providing Credentials to the SDK The SDK provides a service builder that can be used to share configuration values across multiple clients. The service builder allows you to specify default configuration values (e.g., credentials and regions) that are used by every client. The service builder is configured using either JSON configuration files or PHP scripts that return an array.
Providing Credentials to the SDK // Instantiate the S3 client with your AWS credentials $s3Client = S3Client::factory(array( 'credentials' => $credentials )); You may also want to read the section in the Getting Started Guide about using a client's factory method for more details. Setting credentials after instantiation At any time after instantiating the client, you can set the credentials the client should use with the setCredentials() method.
Providing Credentials to the SDK Note Temporary credentials generated by AWS STS are not supported by every service. Please check if the service you are using supports temporary credentials by reading AWS Services that Support AWS STS. Getting temporary credentials AWS STS has several operations that return temporary credentials, but the GetSessionToken operation is the simplest for demonstration purposes.
Configuring the SDK However, the best way to provide temporary credentials is to use the createCredentials() helper method included with the StsClient. This method extracts the data from an AWS STS result and creates the Credentials object for you. $result = $stsClient->getSessionToken(); $credentials = $stsClient->createCredentials($result); $s3Client = S3Client::factory(array('credentials' => $credentials)); You can also use the same technique when setting credentials on an existing client object.
Configuring the SDK $aws = Aws::factory(array( 'key' => 'YOUR_AWS_ACCESS_KEY_ID', 'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY', 'region' => 'us-east-1', )); Using a custom configuration file You can use a custom configuration file that allows you to create custom named clients with pre-configured settings. Let's say you want to use the default aws-config.php settings, but you want to supply your keys using a configuration file.
Configuring the SDK ) ) ); If you prefer JSON syntax, you can define your configuration in JSON format instead of PHP. { "includes": ["_aws"], "services": { "default_settings": { "params": { "key": "your-aws-access-key-id", "secret": "your-aws-secret-access-key", "region": "us-west-2" } } } } For more information about writing custom configuration files, please see Using the Service Builder in the Guzzle documentation.
Configuring the SDK signature.service The signature service scope for Signature V4. See Setting a custom endpoint. signature.region The signature region scope for Signature V4. See Setting a custom endpoint. Generic Client Options Options Description ssl.
Command Objects $client = DynamoDbClient::factory(array( 'base_url' => 'http://my-custom-url', 'region' => 'my-region-1', 'key' => 'abc', 'secret' => '123' )); If your custom endpoint uses signature version 4 and must be signed with custom signature scoping values, then you can specify the signature scoping values using signature.service (the scoped name of the service) and signature.region (the region that you are contacting). These values are typically not required.
Command Objects $command = $dynamoDbClient->getCommand('DescribeTable', array( 'TableName' => 'YourTableName', )); $result = $command->getResult(); A Command is an object that represents the execution of a service operation. Command objects are an abstraction of the process of formatting a request to a service, executing the request, receiving the response, and formatting the results. Commands are created and executed by the client and contain references to Request and Response objects.
Command Objects // 2. Prepare $command->prepare(); $request = $command->getRequest(); // Note: `prepare()` also returns the request object // 3. Execute $command->execute(); $response = $command->getResponse(); $result = $command->getResult(); // Note: `execute()` also returns the result object This is nice, because it gives you a chance to modify the request before it is actually sent.
Waiters // Execute an array of command objects to do them in parallel $s3Client->execute($commands); // Loop over the commands, which have now all been executed foreach ($commands as $command) { $result = $command->getResult(); // Do something with result } Error handling with parallel commands When executing commands in parallel, error handling becomes a bit trickier.
Waiters $s3Client->waitUntilBucketExists(array( 'Bucket' => 'my-bucket', 'waiter.interval' => 10, 'waiter.max_attempts' => 3 )); Waiter Objects To interact with the waiter object directly, you must use the getWaiter() method. The following code is equivalent to the example in the preceding section.
Waiters namespace MyApp\FakeWaiters { use Aws\Common\Waiter\AbstractResourceWaiter; class SleptThreeTimes extends AbstractResourceWaiter { public function doWait() { if ($this->attempts < 3) { echo "Need to sleep…\n"; return false; } else { echo "Now I've slept 3 times.
Iterators 'VaultExists' => array( 'extends' => '__VaultState', 'success.type' => 'output', 'description' => 'Wait until a vault can be accessed.', 'ignore_errors' => array( 'ResourceNotFoundException', ), ), 'VaultNotExists' => array( 'extends' => '__VaultState', 'description' => 'Wait until a vault is deleted.', 'success.type' => 'error', 'success.value' => 'ResourceNotFoundException', ), ), // ... ); In order for you to contribute waiters to the SDK, you will need to implement them using the waiters DSL.
Iterators Iterator Objects The actual object returned by getIterator(), and any get[…]Iterator() method, is an instance of the Aws\Common\Iterator\AwsResourceIterator class (see the API docs for more information about its methods and properties). This class implements PHP's native Iterator interface, which is why it works with foreach, can be used with iterator functions like iterator_to_array, and integrates well with SPL iterators like LimitIterator.
Modeled Responses echo "Results received. {$requestCount} request(s) made so far.\n"; }); foreach ($iterator as $object) { echo $object['Key'] . "\n"; } Modeled Responses Introduction The result of a performing an operation is what we refer to as a modeled response. Instead of returning the raw XML or JSON data, the SDK will coerce the data into an associative array and normalize some aspects of the data based on its knowledge of the specific service and the underlying response structure.
Modeled Responses } $isDeleted = (bool) $result->get('DeleteMarker'); Of course, you can still use isset() checks if you want to, since Model does implement ArrayAccess. The model object (and underlying Collection object) also has convenience methods for finding and checking for keys and values. // You can use isset() since the object implements ArrayAccess if (!isset($result['ContentLength'])) { echo "Empty file.
Static Client Facades Response Models contain the parsed data from the response from a service operation, so the contents of the model will be different depending on which operation you've performed. The SDK's API docs are the best resource for discovering what the model object will contain for a given operation. The API docs contain a full specification of the data in the response model under the Returns section of the docs for an operation (e.g., S3 GetObject operation, EC2 RunInstances operation).
Static Client Facades Version 2.4 of the AWS SDK for PHP adds the ability to enable and use static client "facades". These facades provide an easy, static interface to service clients available in the service builder.
Static Client Facades 'Body' => fopen($file, 'r'), )); echo "\nCreated a new object: {$result['ObjectURL']}\n"; You can also mount the facades into a namespace other than the global namespace. For example, if you wanted to make the client facades available in the "Services" namespace, then you could do the following: Aws::factory('/path/to/my_config.
Performance Guide ->method('listBuckets') ->will($this->returnValue(new Model(array( 'Buckets' => array( array('Name' => 'foo'), array('Name' => 'bar'), array('Name' => 'baz') ) )))); $this->serviceBuilder->set('s3', $mockS3Client); // Test the FileBrowser object that uses the S3 client facade internally $fileBrowser = new FileBrowser(); $partitions = $fileBrowser->getPartitions(); $this->assertEquals(array('foo', 'bar', 'baz'), $partitions); } } Alternatively, if you are specifically only mocking response
Performance Guide We have taken great care to ensure that the SDK will perform well in an environment that utilizes an opcode cache. Note PHP 5.5 comes with an opcode http://php.net/manual/en/book.opcache.php cache that is installed and enabled by default: If you are using PHP 5.5, then you may skip the remainder of this section. APC If you are not able to run PHP 5.5, then we recommend using APC as an opcode cache.
Performance Guide From the PHP documentation This defaults to on, forcing APC to stat (check) the script on each request to determine if it has been modified. If it has been modified it will recompile and cache the new version. If this setting is off, APC will not check, which usually means that to force APC to recheck files, the web server will have to be restarted or the cache will have to be manually cleared. Note that FastCGI web server configurations may not clear the cache on restart.
Performance Guide 'validation' => false )); Cache instance profile credentials When you do not provide credentials to the SDK and do not have credentials defined in your environment variables, the SDK will attempt to utilize IAM instance profile credentials by contacting the Amazon EC2 instance metadata service (IMDS). Contacting the IMDS requires an HTTP request to retrieve credentials from the IMDS.
Frequently Asked Questions (FAQ) Profile your code to find performance bottlenecks You will need to profile your application to determine the bottlenecks. This can be done using Xdebug, XHProf, strace, and various other tools. There are many resources available on the internet to help you track down performance problems with your application. Here are a few that we have found useful: • http://talks.php.net/show/devconf/0 • http://talks.php.
Frequently Asked Questions (FAQ) $aws = Aws\Common\Aws::factory(array( 'region' => 'us-west-2', 'key' => '****', 'secret' => '****', 'ssl.certificate_authority' => '/path/to/updated/cacert.pem' )); You can find out more about how cURL bundles the CA bundle here: http://curl.haxx.se/docs/caextract.
Frequently Asked Questions (FAQ) use use use use Guzzle\Common\Log\MonologLogAdapter; Guzzle\Plugin\Log\LogPlugin; Monolog\Logger; Monolog\Handler\StreamHandler; // Create a log channel $log = new Logger('aws'); $log->pushHandler(new StreamHandler('/path/to/your.
Auto Scaling ...Or by using the the tilde operator. The following statement is equivalent to >=2.4.9,<2.5: { "require": { "aws/aws-sdk-php": "~2.4.9" } } See the Composer documentation for more information on configuring your dependencies. The SDK may at some point adopt the semver standard, but this will probably not happen until the next paradigm-type change. Why am I seeing a "Cannot redeclare class" error? We have observed this error a few times when using the aws.phar from the CLI with APC enabled.
Auto Scaling use Aws\AutoScaling\AutoScalingClient; $client = AutoScalingClient::factory(array( 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
AWS CloudFormation DescribeTags DescribeTerminationPolicyTypes DisableMetricsCollection EnableMetricsCollection ExecutePolicy PutNotificationConfiguration PutScalingPolicy PutScheduledUpdateGroupAction ResumeProcesses SetDesiredCapacity SetInstanceHealth SuspendProcesses TerminateInstanceInAutoScalingGroup UpdateAutoScalingGroup AWS CloudFormation This guide focuses on the AWS SDK for PHP client for AWS CloudFormation.
Amazon CloudFront This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources at https://github.
Amazon CloudFront // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.json'); // Get the client from the builder by namespace $client = $aws->get('CloudFront'); Signing CloudFront URLs for Private Distributions Signed URLs allow you to provide users access to your private content. A signed information (e.g.
Amazon CloudFront $signedUrlCannedPolicy = $cloudFront->getSignedUrl(array( 'url' => $streamHostUrl . '/' . $resourceKey, 'expires' => $expires, 'private_key' => '/path/to/your/cloudfront-private-key.pem', 'key_pair_id' => '' )); To use a custom policy, provide the policy key instead of expires.
Amazon CloudFront (2012-05-05) ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources at https://github.com/aws/aws-sdk-php/tree/master/docs. API Reference Please see the Amazon CloudFront Client API reference for a details about all of the available methods, including descriptions of the inputs and outputs.
Amazon CloudFront (2012-05-05) A more robust way to connect to Amazon CloudFront is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file. These settings can then be shared across all clients so that you only have to specify your settings once. use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.
Amazon CloudFront (2012-05-05) 'url' => $streamHostUrl . '/' . $resourceKey, 'expires' => $expires, )); For versions of the SDK later than 2.3.1, instead of providing your private key information when you instantiate the client, you can provide it at the time when you sign the URL. $signedUrlCannedPolicy = $cloudFront->getSignedUrl(array( 'url' => $streamHostUrl . '/' . $resourceKey, 'expires' => $expires, 'private_key' => '/path/to/your/cloudfront-private-key.
Amazon CloudSearch This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources at https://github.
AWS CloudTrail Service builder A more robust way to connect to Amazon CloudSearch is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file. These settings can then be shared across all clients so that you only have to specify your settings once. use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.
Amazon CloudWatch A region parameter is also required and must be set to one of the following values: us-west-2, us-east-1 use Aws\CloudTrail\CloudTrailClient; $client = CloudTrailClient::factory(array( 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACC
Amazon CloudWatch This guide focuses on the AWS SDK for PHP client for Amazon CloudWatch. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started. Creating a client First you need to create a client object using one of the following techniques. Factory method The easiest way to get up and running quickly is to use the Aws\CloudWatch\CloudWatchClient::factory() method and provide your credentials (key and secret).
AWS Data Pipeline DescribeAlarms DescribeAlarmsForMetric DisableAlarmActions EnableAlarmActions GetMetricStatistics ListMetrics PutMetricAlarm PutMetricData SetAlarmState AWS Data Pipeline This guide focuses on the AWS SDK for PHP client for AWS Data Pipeline. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started.
AWS Direct Connect pull request to https://github.com/aws/aws-sdk-php. https://github.com/aws/aws-sdk-php/tree/master/docs. You can view our documentation sources at API Reference Please see the AWS Data Pipeline Client API reference for a details about all of the available methods, including descriptions of the inputs and outputs.
Amazon DynamoDB $aws = Aws::factory('/path/to/my_config.json'); // Get the client from the builder by namespace $client = $aws->get('DirectConnect'); This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx.
Amazon DynamoDB 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Amazon DynamoDB is through the service builder.
Amazon DynamoDB // Wait until the table is created and active $client->waitUntilTableExists(array( 'TableName' => 'errors' )); A full list of the parameters available to the createTable() operation can be found in the API documentation. For more information about using Local Secondary Indexes, please see the Local secondary indexes section of this guide. Updating a table You can also update the table after it's been created using the updateTable() method.
Amazon DynamoDB echo $tableName . "\n"; } Iterating over all tables The result of a listTables() operation might be truncated. Because of this, it is usually better to use an iterator to retrieve a complete list of all of the tables owned by your account in a specific region. The iterator will automatically handle sending any necessary subsequent requests. $iterator = $client->getIterator('ListTables'); foreach ($iterator as $tableName) { echo $tableName .
Amazon DynamoDB Retrieving items You can check if the item was added correctly using the getItem() method of the client. Because Amazon DynamoDB works under an 'eventual consistency' model, we need to specify that we are performing a consistent read operation.
Amazon DynamoDB Let's say we want a list of all "1201" errors that occurred in the last 15 minutes. We could issue a single query that will search by the primary key of the table and retrieve up to 1MB of the items. However, a better approach is to use the query iterator to retrieve the entire list of all items matching the query.
Amazon DynamoDB echo $item['error']['S'] . "\n"; } Deleting items To delete an item you must use the DeleteItem() method. The following example scans through a table and deletes every item one by one.
Amazon DynamoDB 'KeySchema' => array( array('AttributeName' => 'CustomerId', 'KeyType' => 'HASH'), array('AttributeName' => 'OrderId', 'KeyType' => 'RANGE'), ), 'LocalSecondaryIndexes' => array( array( 'IndexName' => 'OrderDateIndex', 'KeySchema' => array( array('AttributeName' => 'CustomerId', 'KeyType' => 'HASH'), array('AttributeName' => 'OrderDate', 'KeyType' => 'RANGE'), ), 'Projection' => array( 'ProjectionType' => 'KEYS_ONLY', ), ), ), 'ProvisionedThroughput' => array( 'ReadCapacityUnits' => 10, 'Wr
Amazon DynamoDB array( 'PutRequest' => array( 'Item' => array( 'CustomerId' => 'OrderId' => 'OrderDate' => 'ItemId' => ) ) ) array('N' array('N' array('N' array('N' => => => => 941), 3), strtotime('-1 days')), 25336) ) ) )); When you query the table with an LSI, you must specify the name of the index using the IndexName parameter. The attributes that are returned will depend on the value of the Select parameter and on what the table is projecting to the index.
Amazon DynamoDB (2011-12-05) 'id' => $itemId, 'timestamp' => time(), )); $putBatch->add(new PutRequest($item, $tableName)); } $putBatch->flush(); You can also use the WriteRequestBatch object to delete items in batches.
Amazon DynamoDB (2011-12-05) 'region' => '', 'version' => '2011-12-05' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Amazon DynamoDB is through the service builder.
Amazon DynamoDB (2011-12-05) // Update the provisioned throughput capacity of the table $client->updateTable(array( 'TableName' => 'errors', 'ProvisionedThroughput' => array( 'ReadCapacityUnits' => 15, 'WriteCapacityUnits' => 25 ) )); // Wait until the table is active again after updating $client->waitUntilTableExists(array( 'TableName' => 'errors' )); Describing a table Now that the table is created, you can use the describeTable() method to get information about the table.
Amazon DynamoDB (2011-12-05) Tip You can convert an iterator to an array using the toArray() method of the iterator. Adding items You can add an item to our errors table using the putItem() method of the client.
Amazon DynamoDB (2011-12-05) echo $result['Item']['message']['S'] . "\n"; //> no vacant areas You can also retrieve items in batches of up to 100 using the BatchGetItem() method. $tableName = 'errors'; $keys = array(); // Given that $keyValues contains a list of your hash and range keys: // array(array(, ), ...
Amazon DynamoDB (2011-12-05) echo $item['error']['S'] . "\n"; } Scan A scan operation scans the entire table. You can specify filters to apply to the results to refine the values returned to you, after the complete scan. Amazon DynamoDB puts a 1MB limit on the scan (the limit applies before the results are filtered). A scan can be useful for more complex searches.
Amazon Elastic Compute Cloud If you have a large array of items you wish to add to your table, you could iterate over the them, add each item to the batch object. After all the items are added call flush(). The batch object will automatically flush the batch and write items to Amazon DynamoDB after hitting a customizable threshold. A final call to the batch object's flush() method is necessary to transfer any remaining items in the queue.
Amazon Elastic Compute Cloud The easiest way to get up and running quickly is to use the Aws\Ec2\Ec2Client::factory() method and provide your credentials (key and secret).
Amazon Elastic Compute Cloud 81 CancelConversionTask CancelExportTask CancelReservedInstancesListing CancelSpotInstanceRequests ConfirmProductInstance CopyImage CopySnapshot CreateCustomerGateway CreateDhcpOptions CreateImage CreateInstanceExportTask CreateInternetGateway CreateKeyPair CreateNetworkAcl CreateNetworkAclEntry CreateNetworkInterface CreatePlacementGroup CreateReservedInstancesListing CreateRoute CreateRouteTable CreateSecurityGroup CreateSnapshot CreateSpotDatafeedSubsc
Amazon ElastiCache DescribeSnapshots DescribeSpotDatafeedSubscription DescribeSpotInstanceRequests DescribeSpotPriceHistory DescribeSubnets DescribeTags DescribeVolumeAttribute DescribeVolumeStatus DescribeVolumes DescribeVpcAttribute DescribeVpcs DescribeVpnConnections DescribeVpnGateways DetachInternetGateway DetachNetworkInterface DetachVolume DetachVpnGateway DisableVgwRoutePropagation DisassociateAddress DisassociateRouteTable EnableVgwRoutePropagation EnableVolumeIO GetConsoleOu
Amazon ElastiCache A region parameter is also required and must be set to one of the following values: us-east-1, ap-northeast-1, sa-east-1, ap-southeast-1, ap-southeast-2, us-west-2, us-west-1, cn-north-1, eu-west-1 use Aws\ElastiCache\ElastiCacheClient; $client = ElastiCacheClient::factory(array( 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Ide
AWS Elastic Beanstalk DescribeEvents DescribeReplicationGroups DescribeReservedCacheNodes DescribeReservedCacheNodesOfferings ModifyCacheCluster ModifyCacheParameterGroup ModifyCacheSubnetGroup ModifyReplicationGroup PurchaseReservedCacheNodesOffering RebootCacheCluster ResetCacheParameterGroup RevokeCacheSecurityGroupIngress AWS Elastic Beanstalk This guide focuses on the AWS SDK for PHP client for AWS Elastic Beanstalk.
Elastic Load Balancing ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources at https://github.com/aws/aws-sdk-php/tree/master/docs. API Reference Please see the AWS Elastic Beanstalk Client API reference for a details about all of the available methods, including descriptions of the inputs and outputs.
Amazon Elastic Transcoder You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Elastic Load Balancing is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file.
Amazon Elastic Transcoder This guide focuses on the AWS SDK for PHP client for Amazon Elastic Transcoder. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started. Creating a client First you need to create a client object using one of the following techniques.
Amazon Elastic MapReduce CancelJob CreateJob CreatePipeline CreatePreset DeletePipeline DeletePreset ListJobsByPipeline ListJobsByStatus ListPipelines ListPresets ReadJob ReadPipeline ReadPreset TestRole UpdatePipeline UpdatePipelineNotifications UpdatePipelineStatus Amazon Elastic MapReduce This guide focuses on the AWS SDK for PHP client for Amazon Elastic MapReduce. This guide assumes that you have already downloaded and installed the AWS SDK for PHP.
Amazon Glacier This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.com/aws/aws-sdk-php. You can view our documentation sources at https://github.
AWS Identity and Access Management A more robust way to connect to Amazon Glacier is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file. These settings can then be shared across all clients so that you only have to specify your settings once. use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.
AWS Identity and Access Management use Aws\Iam\IamClient; $client = IamClient::factory(array( 'key' => '', 'secret' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
AWS Import/Export DeleteSigningCertificate DeleteUser DeleteUserPolicy DeleteVirtualMFADevice EnableMFADevice GetAccountPasswordPolicy GetAccountSummary GetGroup GetGroupPolicy GetInstanceProfile GetLoginProfile GetRole GetRolePolicy GetSAMLProvider GetServerCertificate GetUser GetUserPolicy ListAccessKeys ListAccountAliases ListGroupPolicies ListGroups ListGroupsForUser ListInstanceProfiles ListInstanceProfilesForRole ListMFADevices ListRolePolicies ListRoles ListSAMLProviders
Amazon Kinesis You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to AWS Import/Export is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file.
Amazon Kinesis 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Amazon Kinesis is through the service builder.
AWS OpsWorks AWS OpsWorks This guide focuses on the AWS SDK for PHP client for AWS OpsWorks. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started. Creating a client First you need to create a client object using one of the following techniques. Factory method The easiest way to get up and running quickly is to use the Aws\OpsWorks\OpsWorksClient::factory() method and provide your credentials (key and secret).
Amazon Relational Database Service AttachElasticLoadBalancer CloneStack CreateApp CreateDeployment CreateInstance CreateLayer CreateStack CreateUserProfile DeleteApp DeleteInstance DeleteLayer DeleteStack DeleteUserProfile DeregisterElasticIp DeregisterVolume DescribeApps DescribeCommands DescribeDeployments DescribeElasticIps DescribeElasticLoadBalancers DescribeInstances DescribeLayers DescribeLoadBasedAutoScaling DescribeMyUserProfile DescribePermissions DescribeRaidArrays Desc
Amazon Relational Database Service use Aws\Rds\RdsClient; $client = RdsClient::factory(array( 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
Amazon Redshift DescribeDBParameterGroups DescribeDBParameters DescribeDBSecurityGroups DescribeDBSnapshots DescribeDBSubnetGroups DescribeEngineDefaultParameters DescribeEventCategories DescribeEventSubscriptions DescribeEvents DescribeOptionGroupOptions DescribeOptionGroups DescribeOrderableDBInstanceOptions DescribeReservedDBInstances DescribeReservedDBInstancesOfferings DownloadDBLogFilePortion ListTagsForResource ModifyDBInstance ModifyDBParameterGroup ModifyDBSubnetGroup ModifyEven
Amazon Redshift $aws = Aws::factory('/path/to/my_config.json'); // Get the client from the builder by namespace $client = $aws->get('Redshift'); Creating a cluster The primary resource in Amazon Redshift is the cluster. To create a cluster you will use the CreateCluster operation. There are several parameters you can send when creating a cluster, so please refer to the API docs to determine which parameters to use. The following is basic example.
Amazon Route 53 $events = $client->getIterator('DescribeEvents', array( 'StartTime' => strtotime('-3 days'), 'EndTime' => strtotime('now'), )); foreach ($events as $event) { echo "{$event['Date']}: {$event['Message']}\n"; } API Reference Please see the Amazon Redshift Client API reference for a details about all of the available methods, including descriptions of the inputs and outputs.
Amazon Route 53 Creating a client First you need to create a client object using one of the following techniques. Factory method The easiest way to get up and running quickly is to use the Aws\Route53\Route53Client::factory() method and provide your credentials (key and secret).
Amazon Simple Storage Service Amazon Simple Storage Service This guide focuses on the AWS SDK for PHP client for Amazon Simple Storage Service. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started. Creating a client First you need to create a client object using one of the following techniques.
Amazon Simple Storage Service // Create a valid bucket and use a LocationConstraint $result = $client->createBucket(array( 'Bucket' => $bucket, 'LocationConstraint' => \Aws\Common\Enum\Region::US_WEST_2 )); // Get the Location header of the response echo $result['Location'] . "\n"; // Get the request ID echo $result['RequestId'] . "\n"; You'll notice in the above example that we are using the Aws\Common\Enum\Region object to provide the US_WEST_2 constant.
Amazon Simple Storage Service // Upload an object by streaming the contents of a file // $pathToFile should be absolute path to a file on disk $result = $client->putObject(array( 'Bucket' => $bucket, 'Key' => 'data_from_file.txt', 'SourceFile' => $pathToFile, 'Metadata' => array( 'Foo' => 'abc', 'Baz' => '123' ) )); // We can poll the object until it is accessible $client->waitUntilObjectExists(array( 'Bucket' => $this->bucket, 'Key' => 'data_from_file.
Amazon Simple Storage Service // Grab the nested Owner/ID value from the result model using getPath() $result = $client->listBuckets(); echo $result->getPath('Owner/ID') . "\n"; Listing objects in your buckets Listing objects is a lot easier in the new SDK thanks to iterators. You can list all of the objects in a bucket using the ListObjectsIterator. $iterator = $client->getIterator('ListObjects', array( 'Bucket' => $bucket )); foreach ($iterator as $object) { echo $object['Key'] .
Amazon Simple Storage Service // Seek to the beginning of the stream $result['Body']->rewind(); // Read the body off of the underlying stream in chunks while ($data = $result['Body']->read(1024)) { echo $data; } // Cast the body to a primitive string // Warning: This loads the entire contents into memory! $bodyAsString = (string) $result['Body']; Saving objects to a file You can save the contents of an object to a file by setting the SaveAs parameter.
Amazon Simple Storage Service ->setKey('my-object-key') ->setConcurrency(3) ->build(); You can use the Aws\S3\S3Client::upload() method if you just want to upload files and not worry if they are too large to send in a single PutObject operation or require a multipart upload. $client->upload('bucket', 'key', 'object body', 'public-read'); Setting ACLs and Access Control Policies You can specify a canned ACL on an object when uploading: $client->putObject(array( 'Bucket' => 'mybucket', 'Key' => 'data.
Amazon Simple Storage Service The most common scenario is creating a pre-signed URL to GET an object. The easiest way to do this is to use the getObjectUrl method of the Amazon S3 client. This same method can also be used to get an unsigned URL of a public S3 object. // Get a plain URL for an Amazon S3 object $plainUrl = $client->getObjectUrl($bucket, 'data.txt'); // > https://my-bucket.s3.amazonaws.com/data.
Amazon Simple Storage Service echo file_get_contents($signedUrl); // > Hello! Amazon S3 stream wrapper The Amazon S3 stream wrapper allows you to store and retrieve data from Amazon S3 using built-in PHP functions like file_get_contents, fopen, copy, rename, unlink, mkdir, rmdir, etc. See Amazon S3 Stream Wrapper.
Amazon Simple Storage Service 'debug' => true )); More control with the UploadSyncBuilder The uploadDirectory() method is an abstraction layer over the much more powerful Aws\S3\Sync\UploadSyncBuilder. You can use an UploadSyncBuilder object directly if you need more control over the transfer.
Amazon Simple Storage Service debug Set to true to enable debug mode to print information about each download. Setting this value to an fopen resource will write the debug output to a stream rather than to STDOUT. allow_resumable Set to true to allow previously interrupted downloads to be resumed using a Range GET More control with the DownloadSyncBuilder The downloadBucket() method is an abstraction layer over the much more powerful Aws\S3\Sync\DownloadSyncBuilder.
Amazon Simple Email Service GetBucketLocation (service docs) GetBucketLogging (service docs) GetBucketNotification (service docs) GetBucketPolicy (service docs) GetBucketRequestPayment (service docs) GetBucketTagging (service docs) GetBucketVersioning (service docs) GetBucketWebsite (service docs) GetObject (service docs) GetObjectAcl (service docs) GetObjectTorrent (service docs) HeadBucket (service docs) HeadObject (service docs) ListBuckets (service docs) ListMultipartUploads (service docs
Amazon SimpleDB use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.json'); // Get the client from the builder by namespace $client = $aws->get('Ses'); This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx.
Amazon SimpleDB 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Amazon SimpleDB is through the service builder.
Amazon SimpleDB After creating a domain, you are ready to start putting data into it. Domains consist of items, which are described by attribute name-value pairs. Items are added to a domain using the PutAttributes operation.
Amazon Simple Notification Service Because some responses will be truncated and require subsequent requests, it is recommended to always use the Select iterator to easily retrieve an entire result set. $iterator = $client->getIterator('Select', array( 'SelectExpression' => "select * from mydomain where a = '1'" )); foreach ($iterator as $item) { echo $item['Name'] .
Amazon Simple Notification Service A region parameter is also required and must be set to one of the following values: us-east-1, ap-northeast-1, sa-east-1, ap-southeast-1, ap-southeast-2, us-west-2, us-gov-west-1, us-west-1, cn-north-1, eu-west-1 use Aws\Sns\SnsClient; $client = SnsClient::factory(array( 'key' => '', 'secret' => '', 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using
Amazon Simple Queue Service RemovePermission SetEndpointAttributes SetPlatformApplicationAttributes SetSubscriptionAttributes SetTopicAttributes Subscribe Unsubscribe Amazon Simple Queue Service This guide focuses on the AWS SDK for PHP client for Amazon Simple Queue Service. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started.
Amazon Simple Queue Service use Aws\Common\Enum\Size; use Aws\Sqs\Enum\QueueAttribute; $result = $client->createQueue(array( 'QueueName' => 'my-queue', 'Attributes' => array( QueueAttribute::DELAY_SECONDS => 5, QueueAttribute::MAXIMUM_MESSAGE_SIZE => 4 * Size::KB, ), )); $queueUrl = $result->get('QueueUrl'); Or you can also set queue attributes later.
AWS Storage Gateway $result = $client->receiveMessage(array( 'QueueUrl' => $queueUrl, 'WaitTimeSeconds' => 10, )); Note You can also configure long-polling at the queue level by setting the ReceiveMessageWaitTimeSeconds queue attribute. API Reference Please see the Amazon Simple Queue Service Client API reference for a details about all of the available methods, including descriptions of the inputs and outputs.
AWS Storage Gateway Service builder A more robust way to connect to AWS Storage Gateway is through the service builder. This allows you to specify credentials and other configuration settings in a configuration file. These settings can then be shared across all clients so that you only have to specify your settings once. use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.
AWS Security Token Service RetrieveTapeRecoveryPoint ShutdownGateway StartGateway UpdateBandwidthRateLimit UpdateChapCredentials UpdateGatewayInformation UpdateGatewaySoftwareNow UpdateMaintenanceStartTime UpdateSnapshotSchedule AWS Security Token Service This guide focuses on the AWS SDK for PHP client for AWS Security Token Service. This guide assumes that you have already downloaded and installed the AWS SDK for PHP. See Installation for more information on getting started.
AWS Security Token Service AWS STS has five operations that return temporary credentials: AssumeRole, AssumeRoleWithWebIdentity, AssumeRoleWithSAML, GetFederationToken, and GetSessionToken. Using the GetSessionToken operation is trivial, so let's use that one as an example. $result = $client->getSessionToken(); The result for GetSessionToken and the other AWS STS operations always contains a 'Credentials' value. If you print the result (e.g., print_r($result)), it looks like the following: Array ( ...
AWS Support $credentials = $sts->createCredentials($sts->getSessionToken()); $s3->setCredentials($credentials); This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start. Our guides are written in ReStructuredText and generated using Sphinx. Feel free to add some content to our documentation and send a pull request to https://github.
Amazon Simple Workflow Service use Aws\Common\Aws; // Create a service builder using a configuration file $aws = Aws::factory('/path/to/my_config.json'); // Get the client from the builder by namespace $client = $aws->get('Support'); This guide is incomplete This guide is not quite finished. If you are looking for a good way to contribute to the SDK and to the rest of the AWS PHP community, then helping to write documentation is a great place to start.
Amazon Simple Workflow Service 'region' => '' )); You can provide your access keys like in the preceding example, or you can choose to omit them if you are using AWS Identity and Access Management (IAM) roles for EC2 instances or credentials sourced from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. Service builder A more robust way to connect to Amazon Simple Workflow Service is through the service builder.
DynamoDB Session Handler SignalWorkflowExecution StartWorkflowExecution TerminateWorkflowExecution DynamoDB Session Handler Introduction The DynamoDB Session Handler is a custom session handler for PHP that allows developers to use Amazon DynamoDB as a session store. Using DynamoDB for session storage alleviates issues that occur with session handling in a distributed web application by moving sessions off of the local file system and into a shared location.
DynamoDB Session Handler Before you can actually use the session handler, you need to create a table in which to store the sessions. This can be done ahead of time through the AWS Console for Amazon DynamoDB, or you can use the session handler object (which you've already configured with the table name) by doing the following: $sessionHandler->createSessionsTable(5, 5); The two parameters for this function are used to specify the read and write provisioned throughput for the table, respectively.
DynamoDB Session Handler gc_batch_size The batch size used for removing expired sessions during garbage collection. This defaults to 25, which is the maximum size of a single BatchWriteItem operation. This value should also take your provisioned throughput into account as well as the timing of your garbage collection. gc_operation_delay The delay (in seconds) between service operations performed during garbage collection. This defaults to 0.
DynamoDB Session Handler Read via session_start() (Using PessimisticLockingStrategy) • A minimum of 1 write operation. • (Conditional) Additional write operations for each attempt at acquiring a lock on the session. Based on configured lock wait time and retry options. • (Conditional) 1 write operation to delete the session if it is expired. Write via session_write_close() Delete via session_destroy() Garbage Collection • 1 write operation. • 1 write operation. • 0.
Amazon S3 Stream Wrapper )); $sessionHandler->garbageCollect(); You can also use the gc_operation_delay configuration option on the session handler to introduce delays in between the Scan and BatchWriteItem operations that are performed by the garbage collection process.
Amazon S3 Stream Wrapper } // Be sure to close the stream resource when you're done with it fclose($stream); } Opening Seekable streams Streams opened in "r" mode only allow data to be read from the stream, and are not seekable by default. This is so that data can be downloaded from Amazon S3 in a truly streaming manner where previously read bytes do not need to be buffered into memory. If you need a stream to be seekable, you can pass seekable into the stream context options of a function.
Amazon S3 Stream Wrapper PHP's fopen() function requires that a $mode option is specified. The mode option specifies whether or not data can be read or written to a stream and if the file must exist when opening a stream. The Amazon S3 stream wrapper supports the following modes: rA read only stream where the file must already exist. wA write only stream. If the file already exists it will be overwritten. aA write only stream.
Amazon S3 Stream Wrapper copy() Copy an object from one location to another. You can pass options available to the CopyObject operation into the stream context options to modify how the object is copied. // Copy a file on Amazon S3 to another bucket copy('s3://bucket/key', 's3://other_bucket/key'); Working with buckets You can modify and browse Amazon S3 buckets similar to how PHP allows the modification and traversal of directories on your filesystem.
Getting Started Another easy way to list the contents of the bucket is using the Symfony2 Finder component.
Service-Specific Guides • SDK Features • Iterators • Waiters • Command Objects • Parallel Commands • Modeled Responses • Static Client Facades • Frequently Asked Questions (FAQ) • Performance Guide • Contributing to the SDK • Guzzle Documentation Service-Specific Guides • Amazon CloudFront • Using the CloudFront PHP client • PHP API reference • Using the older 2012-05-05 API version • Amazon CloudSearch • Using the Amazon CloudSearch PHP client • PHP API reference • Amazon CloudWatch • Using the CloudWatc
Service-Specific Guides • Amazon Glacier • Using the Amazon Glacier PHP client • PHP API reference • Amazon Kinesis • Using the Kinesis PHP client • PHP API reference • Amazon Redshift • Using the Amazon Redshift PHP client • PHP API reference • Amazon Relational Database Service (Amazon RDS) • Using the Amazon RDS PHP client • PHP API reference • Amazon Route 53 • Using the Route 53 PHP client • PHP API reference • Amazon Simple Email Service (Amazon SES) • Using the Amazon SES PHP client • PHP API refere
Articles from the Blog • Using the CloudTrail PHP client • PHP API reference • AWS Data Pipeline • Using the AWS Data Pipeline PHP client • PHP API reference • AWS Direct Connect • Using the AWS Direct Connect PHP client • PHP API reference • AWS Elastic Beanstalk • Using the Elastic Beanstalk PHP client • PHP API reference • AWS Identity and Access Management (AWS IAM) • Using the IAM PHP client • PHP API reference • AWS Import/Export • Using the AWS Import/Export PHP client • PHP API reference • AWS OpsW
Presentations • Providing credentials to the AWS SDK for PHP • Using Credentials from AWS Security Token Service • Iterating through Amazon DynamoDB Results • Sending requests through a proxy • Wire Logging in the AWS SDK for PHP • Streaming Amazon S3 Objects From a Web Server • Static Service Client Facades Presentations Slides • Mastering the AWS SDK for PHP • Getting Good with the AWS SDK for PHP • Using DynamoDB with the AWS SDK for PHP • Controlling the AWS Cloud with PHP Videos • Mastering the AWS