use React\EventLoop;
use Aws\DynamoDb\DynamoDbClient;
use WyriHaximus\React\RingPHP\HttpClientAdapter;
$loop = EventLoop\Factory::create();
$ddbClient = DynamoDbClient::factory([
'region' => 'ap-northeast-1',
'version' => 'latest',
'key' => '<your aws key>',
'secret' => '<your aws secret>'
'ringphp_handler' => new HttpClientAdapter($loop)
]);
/** @var \Aws\Common\FutureResult $ddbResult */
$ddbResult = $ddbClient->putItem([
'TableName' => 'table_name',
'Item' => [
'id' => [ 'S' => $id ],
'createdTime' => [ 'N' => (string)$createdTime ],
],
'@future' => true
]);
$dbbResult->then(
function ($result) {
/** @var Aws\Common\Result $result **/
echo 'done';
},
function (\Exception $e) {
echo 'fail';
}
);
$loop->run();