Installation guide
$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. The Result object is a what we refer to as a "modeled response".
Using command objects
Using the pseudo-methods for performing operations is shorter and preferred for typical use cases, but command
objects provide greater flexibility and access to additional data.
Manipulating command objects before execution
When you create a command using a client's getCommand() method, it does not immediately execute. Because
commands are lazily executed, it is possible to pass the command object around and add or modify the parameters.
The following examples show how to work with command objects:
// You can add parameters after instantiation
$command = $s3Client->getCommand('ListObjects');
$command->set('MaxKeys', 50);
$command->set('Prefix', 'foo/baz/');
$result = $command->getResult();
// You can also modify parameters
$command = $s3Client->getCommand('ListObjects', array(
'MaxKeys' => 50,
'Prefix' => 'foo/baz/',
));
$command->set('MaxKeys', 100);
$result = $command->getResult();
// The set method is chainable
$result = $s3Client->getCommand('ListObjects')
->set('MaxKeys', 50);
->set('Prefix', 'foo/baz/');
->getResult();
// You can also use array access
$command = $s3Client->getCommand('ListObjects');
$command['MaxKeys'] = 50;
$command['Prefix'] = 'foo/baz/';
$result = $command->getResult();
Also, see the API docs for commands.
Request and response objects
From the command object, you can access the request, response, and result objects. The availability of these
objects depend on the state of the command object.
Managing command state
Commands must be prepared before the request object is available, and commands must executed before the
response and result objects are available.
// 1. Create
$command = $client->getCommand('OperationName');
Command Objects
30