8000 minor #19070 Fix documentation for MongoDB Session Handler (GromNaN) · symfony/symfony-docs@66cdabd · GitHub
[go: up one dir, main page]

Skip to content

Commit 66cdabd

Browse files
committed
minor #19070 Fix documentation for MongoDB Session Handler (GromNaN)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- Fix documentation for MongoDB Session Handler - `database` and `collection` parameters are [required](https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php#L45-L46) by `MongoDbSessionHandler` - `@alcaeus` compatibility package can't be recommended anymore, projects have moved to Doctrine ODM 2. Commits ------- 85b931d Fix documentation for MongoDB Session Handler
2 parents 66a498a + 85b931d commit 66cdabd

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

session.rst

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,14 @@ working MongoDB connection in your Symfony application as explained in the
994994
`DoctrineMongoDBBundle configuration`_ article.
995995

996996
Then, register a new handler service for ``MongoDbSessionHandler`` and pass it
997-
the MongoDB connection as argument:
997+
the MongoDB connection as argument, and the required parameters:
998+
999+
``database``:
1000+
The name of the database
1001+
1002+
``collection``:
1003+
The name of the collection
1004+
9981005

9991006
.. configuration-block::
10001007

@@ -1007,6 +1014,7 @@ the MongoDB connection as argument:
10071014
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
10081015
arguments:
10091016
- '@doctrine_mongodb.odm.default_connection'
1017+
- { database: '%env(MONGODB_DB)%', collection: 'sessions' }
10101018
10111019
.. code-block:: xml
10121020
@@ -1022,6 +1030,10 @@ the MongoDB connection as argument:
10221030
<services>
10231031
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
10241032
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
1033+
<argument type="collection">
1034+
<argument key="database">%env('MONGODB_DB')%</argument>
1035+
<argument key="collection">sessions</argument>
1036+
</argument>
10251037
</service>
10261038
</services>
10271039
</container>
@@ -1039,6 +1051,7 @@ the MongoDB connection as argument:
10391051
$services->set(MongoDbSessionHandler::class)
10401052
->args([
10411053
service('doctrine_mongodb.odm.default_connection'),
1054+
['database' => '%env('MONGODB_DB')%', 'collection' => 'sessions']
10421055
])
10431056
;
10441057
};
@@ -1088,13 +1101,6 @@ configuration option to tell Symfony to use this service as the session handler:
10881101
;
10891102
};
10901103
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-
10981104
That's all! Symfony will now use your MongoDB server to read and write the
10991105
session data. You do not need to do anything to initialize your session
11001106
collection. However, you may want to add an index to improve garbage collection
@@ -1123,7 +1129,11 @@ configure these values with the second argument passed to the
11231129
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
11241130
arguments:
11251131
- '@doctrine_mongodb.odm.default_connection'
1126-
- { id_field: '_guid', 'expiry_field': 'eol' }
1132+
-
1133+
database: '%env(MONGODB_DB)%'
1134+
collection: 'sessions'
1135+
id_field: '_guid'
1136+
expiry_field: 'eol'
11271137
11281138
.. code-block:: xml
11291139
@@ -1138,6 +1148,8 @@ configure these values with the second argument passed to the
11381148
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
11391149
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
11401150
<argument type="collection">
1151+
<argument key="database">%env('MONGODB_DB')%</argument>
1152+
<argument key="collection">sessions</argument>
11411153
<argument key="id_field">_guid</argument>
11421154
<argument key="expiry_field">eol</argument>
11431155
</argument>
@@ -1158,7 +1170,12 @@ configure these values with the second argument passed to the
11581170
$services->set(MongoDbSessionHandler::class)
11591171
->args([
11601172
service('doctrine_mongodb.odm.default_connection'),
1161-
['id_field' => '_guid', 'expiry_field' => 'eol'],
1173+
[
1174+
'database' => '%env('MONGODB_DB')%',
1175+
'collection' => 'sessions'
1176+
'id_field' => '_guid',
1177+
'expiry_field' => 'eol',
1178+
],
11621179
])
11631180
;
11641181
};

0 commit comments

Comments
 (0)
0