From 56e7c68191865441b99f44f90c3a8cbae738017f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 19 Feb 2015 12:41:42 +0100 Subject: [PATCH 1/2] Added a brief explanation about Doctrine DBAL Session Storage --- .../configuration/pdo_session_storage.rst | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/cookbook/configuration/pdo_session_storage.rst b/cookbook/configuration/pdo_session_storage.rst index 7955873d878..86e4387f70f 100644 --- a/cookbook/configuration/pdo_session_storage.rst +++ b/cookbook/configuration/pdo_session_storage.rst @@ -217,3 +217,79 @@ For MSSQL, the statement might look like the following: ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] + +Doctrine DBAL Session Storage +----------------------------- + +Symfony applications can also use a Doctrine DBAL based session storage. This +alternative implementation is very similar to the ``PdoSessionHandler`` explained +above, but uses a Doctrine connection and thus also works with non-PDO-based +drivers like mysqli and OCI8. + +The only significant disadvantage of the Doctrine DBAL session storage comparing +it with ``PdoSessionHandler`` is that you can only configure the name of the +table used to store sessions, but not its column names. + +DBAL Session Storage configuration example: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + framework: + session: + # ... + handler_id: session.handler.dbal + + parameters: + dbal_session_table: session + + services: + # ... + session.handler.dbal: + class: Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler + arguments: ["@doctrine.dbal.default_connection", "%dbal_session_table%"] + + .. code-block:: xml + + + + + + + + + + session + + + + + + + %dbal_session_table% + + + + .. code-block:: php + + // app/config/config.php + use Symfony\Component\DependencyInjection\Definition; + use Symfony\Component\DependencyInjection\Reference; + + $container->loadFromExtension('framework', array( + ..., + 'session' => array( + // ..., + 'handler_id' => 'session.handler.dbal', + ), + )); + + $container->setParameter('pdo.dbal_session_table', 'sess'); + + $storageDefinition = new Definition('Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler', array( + new Reference('doctrine.dbal.default_connection'), + '%dbal_session_table%', + )); + $container->setDefinition('session.handler.dbal', $storageDefinition); From 53fc3d56bb2e7d24d26154227e44588689b61ed9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 19 Feb 2015 13:14:05 +0100 Subject: [PATCH 2/2] Minor fixes --- cookbook/configuration/pdo_session_storage.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cookbook/configuration/pdo_session_storage.rst b/cookbook/configuration/pdo_session_storage.rst index 86e4387f70f..5b335c802d4 100644 --- a/cookbook/configuration/pdo_session_storage.rst +++ b/cookbook/configuration/pdo_session_storage.rst @@ -228,7 +228,7 @@ drivers like mysqli and OCI8. The only significant disadvantage of the Doctrine DBAL session storage comparing it with ``PdoSessionHandler`` is that you can only configure the name of the -table used to store sessions, but not its column names. +table used to store sessions but not its column names. DBAL Session Storage configuration example: @@ -243,8 +243,10 @@ DBAL Session Storage configuration example: handler_id: session.handler.dbal parameters: + # ... dbal_session_table: session + # app/config/services.yml services: # ... session.handler.dbal: @@ -264,6 +266,7 @@ DBAL Session Storage configuration example: session + @@ -279,15 +282,18 @@ DBAL Session Storage configuration example: use Symfony\Component\DependencyInjection\Reference; $container->loadFromExtension('framework', array( - ..., + // ... 'session' => array( - // ..., + // ... 'handler_id' => 'session.handler.dbal', ), )); + // ... $container->setParameter('pdo.dbal_session_table', 'sess'); + // app/config/services.php + // ... $storageDefinition = new Definition('Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler', array( new Reference('doctrine.dbal.default_connection'), '%dbal_session_table%',