Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added a brief explanation about Doctrine DBAL Session Storage
  • Loading branch information
javiereguiluz committed Feb 19, 2015
commit 56e7c68191865441b99f44f90c3a8cbae738017f
76 changes: 76 additions & 0 deletions cookbook/configuration/pdo_session_storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that these paragraphs are true for 2.3, but not for 2.6+ (the DBAL session storage has not been migrated to implement session locking yet AFAIK)

it with ``PdoSessionHandler`` is that you can only configure the name of the
table used to store sessions, but not its column names.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure of the comma here


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

<!-- app/config/config.xml -->
<framework:config>
<!-- ... -->
<framework:session handler-id="session.handler.dbal" cookie-lifetime="3600" auto-start="true"/>
</framework:config>

<parameters>
<!-- ... -->
<parameter key="dbal_session_table">session</parameter>
</parameters>

<services>
<!-- ... -->
<service id="session.handler.dbal" class="Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler">
<argument type="service" id="doctrine.dbal.default_connection" />
<argument>%dbal_session_table%</argument>
</service>
</services>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have a complete example:

<?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:framework="http://symfony.com/schema/dic/symfony" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd  http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> <framework:config> <!-- ... --> <framework:session handler-id="session.handler.dbal" /> </framework:config> <parameters> <!-- ... --> <parameter key="dbal_session_table">session</parameter> </parameters> </container> <!-- app/config/services.xml --> <?xml version="1.0" encoding="UTF-8" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> <!-- ... --> <service id="session.handler.dbal" class="Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler"> <argument type="service" id="doctrine.dbal.default_connection" /> <argument>%dbal_session_table%</argument> </service> </services> </container>

.. code-block:: php

// app/config/config.php
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

$container->loadFromExtension('framework', array(
...,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why arbitrarily doing // ... and then here do ... without the // ?

'session' => array(
// ...,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we doing that ...,? sounds weird

'handler_id' => 'session.handler.dbal',
),
));

$container->setParameter('pdo.dbal_session_table', 'sess');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other examples don't have the pdo. prefix.


$storageDefinition = new Definition('Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler', array(
new Reference('doctrine.dbal.default_connection'),
'%dbal_session_table%',
));
$container->setDefinition('session.handler.dbal', $storageDefinition);