Download and install DynamoDB from official site. For older versions connect with code below:
$client = \Aws\DynamoDb\DynamoDbClient::factory(array(
'region' => 'us-west-2',
'base_url' => 'http://localhost:8000',
'key' => 'x',
'secret' => 'y',
));
For 3.3.1 version:
$client = \Aws\DynamoDb\DynamoDbClient::factory(array(
'region' => 'us-west-2',
'endpoint' => 'http://localhost:8000',
'credentials' => [
'key' => 'x',
'secret' => 'y',
],
'version' => 'latest'
));
Search in nested arrays:
$client->putItem([
'TableName' => $this->model,
'Item' => [
'Id' => ['S' => uniqid()],
'Attrs' => [
'M' => [
'ComponentName' => ['S' => 'Beer'],
'CAS' => [ 'S' => '3432-2-123']
]
]
]
]);
// search by nested key
$iterator = $client->getIterator('Scan', [
'TableName' => $this->model,
'FilterExpression' => 'Attrs.ComponentName = :name',
"ExpressionAttributeValues" => [
":name" => ["S" => "Beer"]
],
]);