pfazzi / dynamo-db-session
A DynamoDb adapter for Symfony session storage
Requires
- php: ^8
- ext-json: *
- aws/aws-sdk-php: ^3.171
- symfony/http-foundation: ^5.2
Requires (Dev)
- doctrine/coding-standard: ^8.2
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^4.3
This package is auto-updated.
Last update: 2025-01-06 00:32:42 UTC
README
DynamoDB Session is a session handler that stores session data in DynamoDB.
Installation
Use the package manager composer to install DynamoDB Session.
composer require pfazzi/dynamo-db-session
Usage
Define a proper service in config/services.yaml
services: pfazzi.dynamo_db_session: class: Pfazzi\Session\DynamoDb\DynamoDbSessionHandler arguments: $tableName: 'dashboard-session-dev' # TODO: change me!
A DynamoDb table needs to exist in the configured region with the given $tableName
option.
The primary key of the table must be a String with key "id".
Tell Symfony to use it as session handler in config/packages/framework.yaml
:
framework: session: handler_id: pfazzi.dynamo_db_session
Create session table programmatically
You can programmatically create the session table using Pfazzi\Session\DynamoDb\SessionTable
class, as in the following example:
$tableName = 'some-session-table-name'; $sdk = new Aws\Sdk([ 'region' => 'eu-central-1', 'version' => 'latest', ]); $dynamodb = $sdk->createDynamoDb(); $sessionTable = new Pfazzi\Session\DynamoDb\SessionTable($dynamodb, $tableName); $sessionTable->create();
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.