Skip to content

Commit 4509b50

Browse files
committed
minor #9493 Document host parameter and external parameters in "How to Use PdoSessionHandler..." (pueppiblue, javiereguiluz)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #9493). Discussion ---------- Document host parameter and external parameters in "How to Use PdoSessionHandler..." I recently had the use case to store sessions via pdo on a docker grid. I noticed the `doctrine/pdo_session_storage.rst` documentation is missing the option to configure a host on the PdoSessionHandler and that the service configuration does not use external environment parameters. - add host parameter to first argument useful when database is on another host e.g. docker grid - wrap parameter values in %env()% - add note how to use external parameters Commits ------- d49d8a7 Remove some unneeded changes a7c3344 Don't use env vars in all config examples 8ea2380 add more trailing comma on last array element #9493 ba5fa52 add trailing comma on last array element #9493 e291746 codestyle cd24113 add documentation for external parameters and pdo host parameter
2 parents c83113e + d49d8a7 commit 4509b50

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

doctrine/pdo_session_storage.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To use it, first register a new handler service:
2424
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
2525
public: false
2626
arguments:
27-
- 'mysql:dbname=mydatabase'
27+
- 'mysql:dbname=mydatabase, host=myhost'
2828
- { db_username: myuser, db_password: mypassword }
2929
3030
.. code-block:: xml
@@ -40,7 +40,7 @@ To use it, first register a new handler service:
4040
4141
<services>
4242
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
43-
<argument>mysql:dbname=mydatabase</argument>
43+
<argument>mysql:dbname=mydatabase, host=myhost</argument>
4444
<argument type="collection">
4545
<argument key="db_username">myuser</argument>
4646
<argument key="db_password">mypassword</argument>
@@ -56,11 +56,17 @@ To use it, first register a new handler service:
5656
5757
$storageDefinition = $container->register(PdoSessionHandler::class)
5858
->setArguments(array(
59-
'mysql:dbname=mydatabase',
60-
array('db_username' => 'myuser', 'db_password' => 'mypassword')
59+
'mysql:dbname=mydatabase, host=myhost',
60+
array('db_username' => 'myuser', 'db_password' => 'mypassword'),
6161
))
6262
;
6363
64+
.. tip::
65+
66+
Configure the database credentials as
67+
:doc:`parameters defined with environment variables </configuration/external_parameters>`
68+
to make your application more secure.
69+
6470
Next, tell Symfony to use your service as the session handler:
6571

6672
.. configuration-block::
@@ -113,8 +119,8 @@ a second array argument to ``PdoSessionHandler``:
113119
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
114120
public: false
115121
arguments:
116-
- 'mysql:dbname=mydatabase'
117-
- { db_table: sessions, db_username: myuser, db_password: mypassword }
122+
- 'mysql:dbname=mydatabase, host=myhost'
123+
- { db_table: 'sessions', db_username: 'myuser', db_password: 'mypassword' }
118124
119125
.. code-block:: xml
120126
@@ -127,7 +133,7 @@ a second array argument to ``PdoSessionHandler``:
127133
128134
<services>
129135
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
130-
<argument>mysql:dbname=mydatabase</argument>
136+
<argument>mysql:dbname=mydatabase, host=myhost</argument>
131137
<argument type="collection">
132138
<argument key="db_table">sessions</argument>
133139
<argument key="db_username">myuser</argument>
@@ -146,7 +152,7 @@ a second array argument to ``PdoSessionHandler``:
146152
147153
$container->register(PdoSessionHandler::class)
148154
->setArguments(array(
149-
'mysql:dbname=mydatabase',
155+
'mysql:dbname=mydatabase, host=myhost',
150156
array('db_table' => 'sessions', 'db_username' => 'myuser', 'db_password' => 'mypassword')
151157
))
152158
;

0 commit comments

Comments
 (0)