1. Go to this page and download the library: Download misantron/dynamite 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/ */
misantron / dynamite example snippets
declare(strict_types=1);
namespace Fixtures;
use Dynamite\AbstractTable;
use Dynamite\Attribute\Groups;
use Dynamite\Enum\KeyTypeEnum;
use Dynamite\Enum\ProjectionTypeEnum;
use Dynamite\Enum\ScalarAttributeTypeEnum;
use Dynamite\TableInterface;
use Dynamite\Schema\Attribute;
#[Groups(['group1'])] // groups can be used optionally with console command
final class UsersTable extends AbstractTable implements TableInterface
{
protected function configure(): void
{
$this
->setTableName('Users')
->addAttributes([
new Attribute('Id', ScalarAttributeTypeEnum::String, KeyTypeEnum::Hash),
new Attribute('Email', ScalarAttributeTypeEnum::String),
])
->addGlobalSecondaryIndex(
'Emails',
ProjectionTypeEnum::KeysOnly,
'Email'
)
->setProvisionedThroughput(1, 1)
;
}
}
declare(strict_types=1);
namespace Fixtures;
use Dynamite\AbstractFixture;
use Dynamite\Attribute\Groups;
use Dynamite\FixtureInterface;
use Dynamite\Schema\Record;
use Dynamite\Schema\Value;
#[Groups(['group1'])] // groups can be used optionally with console command
final class UserFixtures extends AbstractFixture implements FixtureInterface
{
protected function configure(): void
{
$this
->setTableName('Users')
->addRecords([
new Record([
Value::stringValue('Id', 'e5502ec2-42a7-408b-9f03-f8e162b6257e'),
Value::stringValue('Email', '[email protected]'),
Value::boolValue('Active', true),
]),
new Record([
Value::stringValue('Id', 'f0cf458c-4fc0-4dd8-ba5b-eca6dba9be63'),
Value::stringValue('Email', '[email protected]'),
Value::boolValue('Active', true),
]),
])
;
}
}
declare(strict_types=1);
use Dynamite\Loader;
use Dynamite\Serializer\PropertyNameConverter;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Validator\Validation;
$validator = Validation::createValidatorBuilder()
->addLoader(new AnnotationLoader())
->getValidator()
;
$serializer = new Serializer([
new BackedEnumNormalizer(),
new ObjectNormalizer(null, new PropertyNameConverter()),
]);
$loader = new Loader($validator, $serializer);
$loader->loadFromDirectory('/path/to/YourFixtures');
declare(strict_types=1);
use Dynamite\Client;
use Dynamite\Executor;
use Dynamite\Loader;
use Dynamite\Serializer\PropertyNameConverter;
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Validator\Validation;
$validator = Validation::createValidatorBuilder()
->addLoader(new AnnotationLoader())
->getValidator()
;
$serializer = new Serializer([
new BackedEnumNormalizer(),
new ObjectNormalizer(null, new PropertyNameConverter()),
]);
$clientFactory = new ClientFactory($serializer);
$loader = new Loader($validator, $serializer);
$loader->loadFromDirectory('/path/to/YourFixtures');
$groups = ['group1']; // loading fixtures belong to the selected group only
$executor = new Executor($clientFactory->createAsyncAwsClient());
$executor->execute($loader->getFixtures($groups), $loader->getTables($groups));
declare(strict_types=1);
use Dynamite\Executor;
// PSR-3 compatible implementation of Psr\Log\LoggerInterface
$logger = new Logger();
$executor = new Executor($client, logger: $logger);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.