Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added a brief explanation about Doctrine DBAL Session Storage#5019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
javiereguiluz wants to merge2 commits intosymfony:2.3fromjaviereguiluz:fix_881
Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletionscookbook/configuration/pdo_session_storage.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -217,3 +217,85 @@ 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.

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

# app/config/services.yml
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>

<!-- app/config/services.xml -->
<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" ?><containerxmlns="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:sessionhandler-id="session.handler.dbal" />    </framework:config>    <parameters><!-- ...-->        <parameterkey="dbal_session_table">session</parameter>    </parameters></container><!-- app/config/services.xml--><?xml version="1.0" encoding="UTF-8" ?><containerxmlns="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><!-- ...-->        <serviceid="session.handler.dbal"class="Symfony\Bridge\Doctrine\HttpFoundation\DbalSessionHandler">            <argumenttype="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(
// ...
'session' => array(
// ...
'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 thepdo. prefix.


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

[8]ページ先頭

©2009-2025 Movatter.jp