@@ -25,15 +25,6 @@ need to change/add some parameters in the main configuration file:
25
25
cookie_lifetime : 2592000 # optional, it is set to 30 days here
26
26
gc_maxlifetime : 2592000 # optional, it is set to 30 days here
27
27
28
- parameters :
29
- # ...
30
- mongo.session.options :
31
- database : session_db # your MongoDB database name
32
- collection : session # your MongoDB collection name
33
- mongodb_host : 1.2.3.4 # your MongoDB server's IP
34
- mongodb_username : my_username
35
- mongodb_password : my_password
36
-
37
28
services :
38
29
# ...
39
30
mongo_client :
@@ -68,19 +59,6 @@ need to change/add some parameters in the main configuration file:
68
59
/>
69
60
</framework : config >
70
61
71
- <parameters >
72
- <parameter key =" mongo.session.options" type =" collection" >
73
- <!-- your MongoDB database name -->
74
- <parameter key =" database" >session_db</parameter >
75
- <!-- your MongoDB collection name -->
76
- <parameter key =" collection" >session</parameter >
77
- </parameter >
78
- <!-- your MongoDB server's IP -->
79
- <parameter key =" mongodb_host" >1.2.3.4</parameter >
80
- <parameter key =" mongodb_username" >my_username</parameter >
81
- <parameter key =" mongodb_password" >my_password</parameter >
82
- </parameters >
83
-
84
62
<services >
85
63
<service id =" mongo_client" class =" MongoClient" >
86
64
<!-- if using a username and password -->
@@ -110,14 +88,6 @@ need to change/add some parameters in the main configuration file:
110
88
),
111
89
));
112
90
113
- $container->setParameter('mongo.session.options', array(
114
- 'database' => 'session_db', // your MongoDB database name
115
- 'collection' => 'session', // your MongoDB collection name
116
- ));
117
- $container->setParameter('mongodb_host', '1.2.3.4'); // your MongoDB server's IP
118
- $container->setParameter('mongodb_username', 'my_username');
119
- $container->setParameter('mongodb_password', 'my_password');
120
-
121
91
$container->setDefinition('mongo_client', new Definition('MongoClient', array(
122
92
// if using a username and password
123
93
array('mongodb://%mongodb_username%:%mongodb_password%@%mongodb_host%:27017'),
@@ -130,6 +100,61 @@ need to change/add some parameters in the main configuration file:
130
100
array(new Reference('mongo_client'), '%mongo.session.options%')
131
101
));
132
102
103
+ The parameters used above should be defined somewhere in your application, often in your main
104
+ parameters configuration:
105
+
106
+ .. configuration-block ::
107
+
108
+ .. code-block :: yaml
109
+
110
+ # app/config/parameters.yml
111
+ parameters :
112
+ # ...
113
+ mongo.session.options :
114
+ database : session_db # your MongoDB database name
115
+ collection : session # your MongoDB collection name
116
+ mongodb_host : 1.2.3.4 # your MongoDB server's IP
117
+ mongodb_username : my_username
118
+ mongodb_password : my_password
119
+
120
+ .. code-block :: xml
121
+
122
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
123
+ <container xmlns =" http://symfony.com/schema/dic/services"
124
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-Instance"
125
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
126
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
127
+ http://symfony.com/schema/dic/services/services-1.0.xsd
128
+ http://symfony.com/schema/dic/symfony
129
+ http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
130
+
131
+ <parameters >
132
+ <parameter key =" mongo.session.options" type =" collection" >
133
+ <!-- your MongoDB database name -->
134
+ <parameter key =" database" >session_db</parameter >
135
+ <!-- your MongoDB collection name -->
136
+ <parameter key =" collection" >session</parameter >
137
+ </parameter >
138
+ <!-- your MongoDB server's IP -->
139
+ <parameter key =" mongodb_host" >1.2.3.4</parameter >
140
+ <parameter key =" mongodb_username" >my_username</parameter >
141
+ <parameter key =" mongodb_password" >my_password</parameter >
142
+ </parameters >
143
+ </container >
144
+
145
+ .. code-block :: php
146
+
147
+ use Symfony\Component\DependencyInjection\Reference;
148
+ use Symfony\Component\DependencyInjection\Definition;
149
+
150
+ $container->setParameter('mongo.session.options', array(
151
+ 'database' => 'session_db', // your MongoDB database name
152
+ 'collection' => 'session', // your MongoDB collection name
153
+ ));
154
+ $container->setParameter('mongodb_host', '1.2.3.4'); // your MongoDB server's IP
155
+ $container->setParameter('mongodb_username', 'my_username');
156
+ $container->setParameter('mongodb_password', 'my_password');
157
+
133
158
Setting Up the MongoDB Collection
134
159
---------------------------------
135
160
0 commit comments