PHP code example of craftcms / yii2-dynamodb

1. Go to this page and download the library: Download craftcms/yii2-dynamodb 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/ */

    

craftcms / yii2-dynamodb example snippets


use craftcms\dynamodb\DynamoDbCache;

return [
    'bootstrap' => [
        'cache',
    ],
    'components' => [
        'cache' => [
            'class' => DynamoDbCache::class,
            'dataAttribute' => 'data', // optional: defaults to data
            'dynamoDb' => [
                'table' => 'my-app-cache-table',
                'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
                'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
                'region' => '<region>', // optional: defaults to AWS_REGION env var
                'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
                'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
                'credentials' => [
                    'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
                    'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
                ],
            ],
        ],
    ],
];

use craftcms\dynamodb\DynamoDbSession;

return [
    'bootstrap' => [
        'session',
    ],
    'components' => [
        'session' => [
            'class' => DynamoDbSession::class,
            'dataAttribute' => 'data', // optional: defaults to data
            'dynamoDb' => [
                'table' => 'my-app-session-table',
                'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
                'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
                'region' => '<region>', // optional: defaults to AWS_REGION env var
                'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
                'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
                'credentials' => [
                    'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
                    'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
                ],
            ],
        ],
    ],
];

use craftcms\dynamodb\DynamoDbQueue;

return [
    'bootstrap' => [
        'queue',
    ],
    'components' => [
        'queue' => [
            'class' => DynamoDbQueue::class,
            'dynamoDb' => [
                'table' => 'my-app-queue-table',
                'partitionKeyAttribute' => 'id', // optional: defaults to 'PK'
                'endpoint' => 'http://localhost:8000', // optional: used for local or when using DAX
                'region' => '<region>', // optional: defaults to AWS_REGION env var
                'ttl' => 60*60*24, // optional: number of seconds until items are considered expired
                'ttlAttribute' => 'expires' // optional: defaults to 'TTL'
                'credentials' => [
                    'key' => '<key>', // optional: defaults to AWS_ACCESS_KEY_ID env var
                    'secret' => '<secret>', // optional: defaults to AWS_SECRET_ACCESS_KEY env var
                ],
            ],
        ],
    ],
];