未找到AWS dynamodb PHP'命令匹配Update_table'

I working on a web application and since a lot of read and write action happening in the amazon dynamodb table am facing a provisionthroughput error. Thinking of using a Update table I used below code but facing error. This error is not mentioned in error handling chart of dynamobb.

<?php

use Aws\DynamoDb\DynamoDbClient;

$dynamoDB = DynamoDbClient::factory(array(
    'key' => '', 
    'secret' => '',
    'region' => Region::US_WEST_1
));

####################################################################
# Updating the table
 // $dynamodb = new AmazonDynamoDB();

echo PHP_EOL . PHP_EOL;
echo "# Updating the \"${dynamo_db_table}\" table..." . PHP_EOL;

$up = $dynamoDB->Update_table(array(
    'TableName' => $dynamo_db_table,
    'ProvisionedThroughput' => array(
        'ReadCapacityUnits' => 39,
        'WriteCapacityUnits' => 37
    )
));

$table_status = $dynamoDB->describe_table(array(
    'TableName' => $dynamo_db_table
));

// Check for success...
if ($table_status->isOK())
{
    print_r($table_status->body->Table->ProvisionedThroughput->to_array()->getArrayCopy());
}
else
{
    print_r($table_status);
}       

$count = 0;
do {
    sleep(5);
    $count += 5;

    $response = $dynamoDB->describe_table(array(
        'TableName' => $table_name
    ));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');

echo "The table \"${table_name}\" has been updated (slept ${count} seconds)." . PHP_EOL;
?>

I am facing below error:

# Updating the "tablename" table... 
Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Command was not found matching Update_table' in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php:117 Stack trace: #0 /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php(94): Guzzle\Service\Client->getCommand('Update_table', Array) #1 /home/phretscl/public_html/RETS/vendor/aws/aws-sdk-php/src/Aws/Common/Client/AbstractClient.php(103): Guzzle\Service\Client->__call('Update_table', Array) #2 /home/phretscl/public_html/RETS/file.php(97): Aws\Common\Client\AbstractClient->__call('Update_table', Array) #3 /home/phretscl/public_html/RETS/file.php(97): Aws\DynamoDb\DynamoDbClient->Update_table(Array) #4 {main} thrown in /home/phretscl/public_html/RETS/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 117

The code you are using is not correct. From the error message, I can tell you are using version 2.x of the AWS SDK for PHP, but the code you using from ############ line down looks like it is meant for version 1.x of the AWS SDK for PHP. The error is being thrown, because you are not calling the DynamoDbClient::updateTable() method correctly.

You should checkout the AWS SDK for PHP User Guide, particularly the page about DynamoDB, which has a code sample for UpdateTable.


EDIT w/ regards to the comments: If this is a long running process, you should use the Aws\Common\Aws way of instantiating the client, since it retains and reuses the client objects it creates. Replace you DynamoDbClient::factory(...) code with this:

use Aws\Common\Aws;

$aws = Aws::factory(array(
    'key' => '...', 
    'secret' => '...',
    'region' => Region::US_WEST_1
));

$dynamoDB = $aws->get('dynamodb');

You should provide the credentials like this Also, the region should be like this 'region'=>'us-east-1'

$DDBClient = DynamoDbClient::factory([
                'region'=>'us-east-1',
                'version' => 'latest',
                'credentials' => [
                    'key' => 'XXXXXXXXXX',
                    'secret' => 'XXXXXXXXXXXXX'
                ]
                ,'scheme'  => 'http' // Use this if you don't have HTTPS
                //, 'debug' => true
            ]);