From 264ebcce09a7e51177367c4cc61748a663955afd Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 18 Aug 2023 11:54:17 +0200 Subject: [PATCH] [FrameworkBundle] Add documentation about using a DSN as the `session.handler_id` --- reference/configuration/framework.rst | 74 ++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 52f9e78a823..393760b5a0d 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1608,10 +1608,80 @@ handler_id **type**: ``string`` **default**: ``session.handler.native_file`` -The service id used for session storage. The default value ``'session.handler.native_file'`` +The service id or DSN used for session storage. The default value ``'session.handler.native_file'`` will let Symfony manage the sessions itself using files to store the session metadata. Set it to ``null`` to use the native PHP session mechanism. -You can also :ref:`store sessions in a database `. +It is possible to :ref:`store sessions in a database `, +and also to configure the session handler with a DSN: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/framework.yaml + framework: + session: + # a few possible examples + handler_id: 'redis://localhost' + handler_id: '%env(REDIS_URL)%' + handler_id: '%env(DATABASE_URL)%' + handler_id: 'file://%kernel.project_dir%/var/sessions' + + .. code-block:: xml + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + use function Symfony\Component\DependencyInjection\Loader\Configurator\env; + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework): void { + // ... + + $framework->session() + // a few possible examples + ->handlerId('redis://localhost') + ->handlerId(env('REDIS_URL')) + ->handlerId(env('DATABASE_URL')) + ->handlerId('file://%kernel.project_dir%/var/sessions'); + }; + +.. note:: + + Supported DSN protocols are the following: + + * ``file`` + * ``redis`` + * ``rediss`` (Redis over TLS) + * ``memcached`` (requires :doc:`symfony/cache `) + * ``pdo_oci`` (requires :doc:`doctrine/dbal `) + * ``mssql`` + * ``mysql`` + * ``mysql2`` + * ``pgsql`` + * ``postgres`` + * ``postgresql`` + * ``sqlsrv`` + * ``sqlite`` + * ``sqlite3`` .. _name: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy