Skip to content

Commit 4dd365b

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: - Fix documentation for MongoDB Session Handler
2 parents 178f167 + e0b4107 commit 4dd365b

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
@@ -989,7 +989,14 @@ working MongoDB connection in your Symfony application as explained in the
989989
`DoctrineMongoDBBundle configuration`_ article.
990990

991991
Then, register a new handler service for ``MongoDbSessionHandler`` and pass it
992-
the MongoDB connection as argument:
992+
the MongoDB connection as argument, and the required parameters:
993+
994+
``database``:
995+
The name of the database
996+
997+
``collection``:
998+
The name of the collection
999+
9931000

9941001
.. configuration-block::
9951002

@@ -1002,6 +1009,7 @@ the MongoDB connection as argument:
10021009
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
10031010
arguments:
10041011
- '@doctrine_mongodb.odm.default_connection'
1012+
- { database: '%env(MONGODB_DB)%', collection: 'sessions' }
10051013
10061014
.. code-block:: xml
10071015
@@ -1017,6 +1025,10 @@ the MongoDB connection as argument:
10171025
<services>
10181026
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
10191027
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
1028+
<argument type="collection">
1029+
<argument key="database">%env('MONGODB_DB')%</argument>
1030+
<argument key="collection">sessions</argument>
1031+
</argument>
10201032
</service>
10211033
</services>
10221034
</container>
@@ -1034,6 +1046,7 @@ the MongoDB connection as argument:
10341046
$services->set(MongoDbSessionHandler::class)
10351047
->args([
10361048
service('doctrine_mongodb.odm.default_connection'),
1049+
['database' => '%env("MONGODB_DB")%', 'collection' => 'sessions']
10371050
])
10381051
;
10391052
};
@@ -1083,13 +1096,6 @@ configuration option to tell Symfony to use this service as the session handler:
10831096
;
10841097
};
10851098
1086-
.. note::
1087-
1088-
MongoDB ODM 1.x only works with the legacy driver, which is no longer
1089-
supported by the Symfony session class. Install the ``alcaeus/mongo-php-adapter``
1090-
package to retrieve the underlying ``\MongoDB\Client`` object or upgrade to
1091-
MongoDB ODM 2.0.
1092-
10931099
That's all! Symfony will now use your MongoDB server to read and write the
10941100
session data. You do not need to do anything to initialize your session
10951101
collection. However, you may want to add an index to improve garbage collection
@@ -1118,7 +1124,11 @@ configure these values with the second argument passed to the
11181124
Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler:
11191125
arguments:
11201126
- '@doctrine_mongodb.odm.default_connection'
1121-
- { id_field: '_guid', 'expiry_field': 'eol' }
1127+
-
1128+
database: '%env(MONGODB_DB)%'
1129+
collection: 'sessions'
1130+
id_field: '_guid'
1131+
expiry_field: 'eol'
11221132
11231133
.. code-block:: xml
11241134
@@ -1133,6 +1143,8 @@ configure these values with the second argument passed to the
11331143
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler">
11341144
<argument type="service">doctrine_mongodb.odm.default_connection</argument>
11351145
<argument type="collection">
1146+
<argument key="database">%env('MONGODB_DB')%</argument>
1147+
<argument key="collection">sessions</argument>
11361148
<argument key="id_field">_guid</argument>
11371149
<argument key="expiry_field">eol</argument>
11381150
</argument>
@@ -1153,7 +1165,12 @@ configure these values with the second argument passed to the
11531165
$services->set(MongoDbSessionHandler::class)
11541166
->args([
11551167
service('doctrine_mongodb.odm.default_connection'),
1156-
['id_field' => '_guid', 'expiry_field' => 'eol'],
1168+
[
1169+
'database' => '%env('MONGODB_DB')%',
1170+
'collection' => 'sessions'
1171+
'id_field' => '_guid',
1172+
'expiry_field' => 'eol',
1173+
],
11571174
])
11581175
;
11591176
};

0 commit comments

Comments
 (0)