8000 Fix documentation for MongoDB Session Handler · symfony/symfony-docs@db5024c · GitHub
[go: up one dir, main page]

Skip to content

Commit db5024c

Browse files
committed
Fix documentation for MongoDB Session Handler
1 parent 50617f1 commit db5024c

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

session.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ the MongoDB connection as argument:
10071007
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
10081008
arguments:
10091009
- '@doctrine_mongodb.odm.default_connection'
1010+
- { database: '%env(MONGODB_DB)%', collection: 'sessions' }
10101011
10111012
.. code-block:: xml
10121013
@@ -1022,6 +1023,10 @@ the MongoDB connection as argument:
10221023
<services>
10231024
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
10241025
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
1026+
<argument type="collection">
1027+
<argument key="database">%env('MONGODB_DB')%</argument>
1028+
<argument key="collection">sessions</argument>
1029+
</argument>
10251030
</service>
10261031
</services>
10271032
</container>
@@ -1039,6 +1044,7 @@ the MongoDB connection as argument:
10391044
$services->set(MongoDbSessionHandler::class)
10401045
->args([
10411046
service('doctrine_mongodb.odm.default_connection'),
1047+
['database' => '%env('MONGODB_DB')%', 'collection' => 'sessions']
10421048
])
10431049
;
10441050
};
@@ -1088,13 +1094,6 @@ configuration option to tell Symfony to use this service as the session handler:
10881094
;
10891095
};
10901096
1091-
.. note::
1092-
1093-
MongoDB ODM 1.x only works with the legacy driver, which is no longer
1094-
supported by the Symfony session class. Install the ``alcaeus/mongo-php-adapter``
1095-
package to retrieve the underlying ``\MongoDB\Client`` object or upgrade to
1096-
MongoDB ODM 2.0.
1097-
10981097
That's all! Symfony will now use your MongoDB server to read and write the
10991098
session data. You do not need to do anything to initialize your session
11001099
collection. However, you may want to add an index to improve garbage collection
@@ -1123,7 +1122,11 @@ configure these values with the second argument passed to the
11231122
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
11241123
arguments:
11251124
- '@doctrine_mongodb.odm.default_connection'
1126-
- { id_field: '_guid', 'expiry_field': 'eol' }
1125+
-
1126+
database: '%env(MONGODB_DB)%'
1127+
collection: 'sessions'
1128+
id_field: '_guid'
1129+
expiry_field: 'eol'
11271130
11281131
.. code-block:: xml
11291132
@@ -1138,6 +1141,8 @@ configure these values with the second argument passed to the
11381141
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
11391142
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
11401143
<argument type="collection">
1144+
<argument key="database">%env('MONGODB_DB')%</argument>
1145+
<argument key="collection">sessions</argument>
11411146
<argument key="id_field">_guid</argument>
11421147
<argument key="expiry_field">eol</argument>
11431148
</argument>
@@ -1158,13 +1163,24 @@ configure these values with the second argument passed to the
11581163
$services->set(MongoDbSessionHandler::class)
11591164
->args([
11601165
service('doctrine_mongodb.odm.default_connection'),
1161-
['id_field' => '_guid', 'expiry_field' => 'eol'],
1166+
[
1167+
'database' => '%env('MONGODB_DB')%',
1168+
'collection' => 'sessions'
1169+
'id_field' => '_guid',
1170+
'expiry_field' => 'eol',
1171+
],
11621172
])
11631173
;
11641174
};
11651175
11661176
These are parameters that you can configure:
11671177

1178+
``database``:
1179+
The name of the database
1180+
1181+
``collection``:
1182+
The name of the collection
1183+
11681184
``id_field`` (default ``_id``):
11691185
The name of the field where to store the session ID;
11701186

0 commit comments

Comments
 (0)
0