Installation guide

'key' => '<aws access key>',
'secret' => '<aws secret key>',
'region' => '<region name>'
));
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. 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.json');
// Get the client from the builder by namespace
$client = $aws->get('SimpleDb');
Creating domains
The first step in storing data within Amazon SimpleDB is to create one or more domains.
Domains are similar to database tables, except that you cannot perform functions across multiple domains, such as
querying multiple domains or using foreign keys. As a consequence, you should plan an Amazon SimpleDB data
architecture that will meet the needs of your project.
Let's use the CreateDomain operation of the Amazon SimpleDB client to create a domain.
$client->createDomain(array('DomainName' => 'mydomain'));
List all domains
Now that the domain is created, we can list the domains in our account to verify that it exists. This is done using the
ListDomains operation and the ListDomains iterator.
$domains = $client->getIterator('ListDomains')->toArray();
var_export($domains);
// Lists an array of domain names, including "mydomain"
Retrieving a domain
You can get more information about a domain using the DomainMetadata operation. This operation returns
information about a domain, including when the domain was created, the number of items and attributes, and the
size of attribute names and values.
$result = $client->domainMetadata(array('DomainName' => 'mydomain'));
echo $result['ItemCount'] . "\n";
echo $result['ItemNamesSizeBytes'] . "\n";
echo $result['AttributeNameCount'] . "\n";
echo $result['AttributeNamesSizeBytes'] . "\n";
echo $result['AttributeValueCount'] . "\n";
echo $result['AttributeValuesSizeBytes'] . "\n";
echo $result['Timestamp'] . "\n";
Adding items
Amazon SimpleDB
114