Skip to content

Instantly share code, notes, and snippets.

@igorw
Last active December 22, 2015 09:09
Show Gist options
  • Save igorw/6450089 to your computer and use it in GitHub Desktop.
Save igorw/6450089 to your computer and use it in GitHub Desktop.
<?php
namespace DynamoDbSession;
use Aws\DynamoDb\Session\SessionHandler;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
class DynamoDbSessionServiceProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
$app['session.storage'] = $app->share(function ($app) {
$config = array_merge($app['session.dynamodb.options'], array(
'dynamodb_client' => $app['aws']->get('dynamodb'),
));
$handler = SessionHandler::factory($config);
return new NativeSessionStorage($app['session.storage.options'], $handler);
});
$app['session.dynamodb.options'] = array();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment