PHP code example of matthieuwerner / dynamodb-storable
1. Go to this page and download the library: Download matthieuwerner/dynamodb-storable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
matthieuwerner / dynamodb-storable example snippets
use Storable\Storage;
protected function anyAction(Storage $storage): string
{
$storage->set('key', 'value');
// ...
}
use Storable\Storage;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
protected function anyAction(): string
{
$encoders = [new JsonEncoder()];
$normalizers = [new ObjectNormalizer()];
$storage = new Storage($dynamoDbClientMock, new Serializer($normalizers, $encoders));
$storage->set('key', 'value');
// ...
}
// String
$storage->get('key'); // Return a string
// Object
$storage->get($objectId); // Return an object
$storage->remove('key');
// Get all objects in a namespace
$storage->getByNamespace('namespace');
// Remove all objects in a namespace
$storage->removeNamespace('namespace');
// Change the default table name (default is "storage")
$storage->setTable('newTableName');
// Change the default namespace (default is "main")
$storage->setNamespace('newNamespaceName');
// Change the default attribute "key" in the table structure
$storage->setAttributeKey('newKeyAttribute');
// Change the default attribute "namespace" in the table structure
$storage->setAttributeNamespace('newNamespaceAttribute');
// Change the default attribute "value" in the table structure
$storage->setAttributeValue('newValueAttribute');
// Change the default attribute "class" in the table structure
$storage->setAttributeClass('newClassAttribute');
// Change the default attribute "date" in the table structure
$storage->setAttributeDate('newDateAttribute');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.