Installation guide
$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.
Using a proxy
You can send requests with the AWS SDK for PHP through a proxy using the "request options" of a client. These
"request options" are applied to each HTTP request sent from the client. One of the option settings that can be
specified is the proxy option.
Request options are passed to a client through the client's factory method:
use Aws\S3\S3Client;
$s3 = S3Client::factory(array(
'request.options' => array(
'proxy' => '127.0.0.1:123'
)
));
The above example tells the client that all requests should be proxied through an HTTP proxy located at the
127.0.0.1 IP address using port 123.
You can supply a username and password when specifying your proxy setting if needed, using the format of
username:password@host:port.
Command Objects
Command objects are fundamental to how the SDK works. In normal usage of the SDK, you may never interact with
command objects. However, if you are performing operations in parallel, inspecting data from the request or
response, or writing custom plugins, you will need to understand how they work.
Typical SDK usage
You can perform a service operation by calling the method of the same name on the client object. For example, to
perform the Amazon DynamoDB DescribeTable operation, you must call the
Aws\DynamoDb\DynamoDbClient::describeTable() method. Operation methods, like describeTable(),
all accept a single argument that is an associative array of values representing the parameters to the operation. The
structure of this array is defined for each operation in the SDK's API Documentation (e.g., see the API docs for
describeTable()).
$result = $dynamoDbClient->describeTable(array(
'TableName' => 'YourTableName',
));
A peek under the hood
If you examine a client class, you will see that the methods corresponding to the operations do not actually exist.
They are implemented using the __call() magic method behavior. These pseudo-methods are actually shortcuts
that encapsulate the SDK's — and the underlying Guzzle library's — use of command objects.
For example, you could perform the same DescribeTable operation from the preceding section using command
objects:
Command Objects
29