AWS SDK for PHPをインストール
composer.jsonを編集して、requireに"aws/aws-sdk-php": "2.*""
を追加
...
"require": {
...
"aws/aws-sdk-php": "2.*"
},
...
としても上手くいかなかった
なんか、色々エラーがでて最終的に以下の設定で上手く行った
...
"require": {
...
"guzzlehttp/guzzle": "*",
"aws/aws-sdk-php": "3.*"
},
...
php composer.phar update
を叩く
bootstrap.phpにAWSのnamespaceを追加
\Autoloader::add_namespace('Aws', APPPATH.'vendor/aws/aws-sdk-php/src/Aws', true);
classesにaws/dyanamodb.phpを作成
```
<?php
use Aws\Common\Aws;
use Aws\DynamoDb\DynamoDbClient;
class Aws_Dynamo
{
// aws設定
public static $config = array(
"region" => "us-east-1",
"version" => "latest",
"endpoint" => "http://dynamodb.リージョン名.amazonaws.com/",
"credentials" => array(
"key" => "key"",
"secret" => "secret",
),
);
// データの登録
public static function putItem($table, $data)
{
$client = DynamoDbClient::factory(Aws_Dynamo::$config);
$client->putItem(array(
"TableName" => $table,
"Item" => $data,
));
}
}
`