@@ -6,8 +6,8 @@ How to Organize Configuration Files
66
77The default Symfony2 Standard Edition defines three
88:doc: `execution environments </cookbook/configuration/environments >` called
9- ``dev ``, ``prod ``, and ``test ``. An environment simply represents a way to
10- execute the same codebase with different configuration .
9+ ``dev ``, ``prod `` and ``test ``. An environment simply represents a way to
10+ execute the same codebase with different configurations .
1111
1212In order to select the configuration file to load for each environment, Symfony
1313executes the ``registerContainerConfiguration() `` method of the ``AppKernel ``
@@ -115,14 +115,21 @@ files, including the common files:
115115
116116 .. code-block :: xml
117117
118- <!-- # app/config/dev/config.xml -->
119- <imports >
120- < import resource = " ../common/config.xml " />
121- < import resource = " parameters.xml " />
122- < import resource = " security.xml " />
123- </ imports >
118+ <!-- app/config/dev/config.xml -->
119+ <? xml version = " 1.0 " encoding = " UTF-8 " ? >
120+ < container xmlns = " http://symfony.com/schema/dic/services "
121+ xmlns : xsi = " http://www.w3.org/2001/XMLSchema-instance "
122+ xsi : schemaLocation = " http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
123+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd " >
124124
125- <!-- ... -->
125+ <imports >
126+ <import resource =" ../common/config.xml" />
127+ <import resource =" parameters.xml" />
128+ <import resource =" security.xml" />
129+ </imports >
130+
131+ <!-- ... -->
132+ </container >
126133
127134 .. code-block :: php
128135
@@ -147,12 +154,21 @@ files, including the common files:
147154
148155 .. code-block :: xml
149156
150- <!-- # app/config/prod/config.xml -->
151- <imports >
152- <import resource =" ../common/config.xml" />
153- <import resource =" parameters.xml" />
154- <import resource =" security.xml" />
155- </imports >
157+ <!-- app/config/prod/config.xml -->
158+ <?xml version =" 1.0" encoding =" UTF-8" ?>
159+ <container xmlns =" http://symfony.com/schema/dic/services"
160+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
161+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
162+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
163+
164+ <imports >
165+ <import resource =" ../common/config.xml" />
166+ <import resource =" parameters.xml" />
167+ <import resource =" security.xml" />
168+ </imports >
169+
170+ <!-- ... -->
171+ </container >
156172
157173 <!-- ... -->
158174
@@ -178,13 +194,20 @@ files, including the common files:
178194
179195 .. code-block :: xml
180196
181- <!-- # app/config/config.xml -->
182- <imports >
183- <import resource =" parameters.xml" />
184- <import resource =" security.xml" />
185- </imports >
197+ <!-- app/config/config.xml -->
198+ <?xml version =" 1.0" encoding =" UTF-8" ?>
199+ <container xmlns =" http://symfony.com/schema/dic/services"
200+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
201+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
202+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
186203
187- <!-- ... -->
204+ <imports >
205+ <import resource =" parameters.xml" />
206+ <import resource =" security.xml" />
207+ </imports >
208+
209+ <!-- ... -->
210+ </container >
188211
189212 .. code-block :: php
190213
@@ -243,14 +266,15 @@ make Symfony aware of the new file organization::
243266 }
244267
245268Following the same technique explained in the previous section, make sure to
246- load the appropriate configuration files from each main file (``common.yml ``,
269+ import the appropriate configuration files from each main file (``common.yml ``,
247270``dev.yml `` and ``prod.yml ``).
248271
249- Advanced Tecniques
250- ------------------
272+ Advanced Techniques
273+ -------------------
251274
252- Symfony loads configuration files using the ``Config component </components/config> ``,
253- which provides some advanced features.
275+ Symfony loads configuration files using the
276+ ``Config component </components/config/introduction> ``, which provides some
277+ advanced features.
254278
255279Mix and Match Configuration Formats
256280~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -273,15 +297,22 @@ format (``.yml``, ``.xml``, ``.php``, ``.ini``):
273297
274298 .. code-block :: xml
275299
276- <!-- # app/config/config.xml -->
277- <imports >
278- <import resource =" parameters.yml" />
279- <import resource =" services.xml" />
280- <import resource =" security.yml" />
281- <import resource =" legacy.php" />
282- </imports >
300+ <!-- app/config/config.xml -->
301+ <?xml version =" 1.0" encoding =" UTF-8" ?>
302+ <container xmlns =" http://symfony.com/schema/dic/services"
303+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
304+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
305+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
283306
284- <!-- ... -->
307+ <imports >
308+ <import resource =" parameters.yml" />
309+ <import resource =" services.xml" />
310+ <import resource =" security.yml" />
311+ <import resource =" legacy.php" />
312+ </imports >
313+
314+ <!-- ... -->
315+ </container >
285316
286317 .. code-block :: php
287318
@@ -297,8 +328,8 @@ format (``.yml``, ``.xml``, ``.php``, ``.ini``):
297328
298329 The ``IniFileLoader `` parses the file contents using the
299330 :phpfunction: `parse_ini_file ` function, therefore, you can only set
300- parameters to string values. To set parameters to other data types
301- (e.g. boolean, integer, etc), the other loaders are recommended .
331+ parameters to string values. Use one of the other loaders if you want
332+ to use other data types (e.g. boolean, integer, etc.) .
302333
303334If you use any other configuration format, you have to define your own loader
304335class extending it from :class: `Symfony\\ Component\\ DependencyInjection\\ Loader\\ FileLoader `.
@@ -319,20 +350,27 @@ by loading an entire directory:
319350
320351 # app/config/config.yml
321352 imports :
322- - { resource: 'bundles/' }
323- - { resource: 'services/' }
353+ - { resource: 'bundles/' }
354+ - { resource: 'services/' }
324355
325356 # ...
326357
327358 .. code-block :: xml
328359
329- <!-- # app/config/config.xml -->
330- <imports >
331- <import resource =" bundles/" />
332- <import resource =" services/" />
333- </imports >
360+ <!-- app/config/config.xml -->
361+ <?xml version =" 1.0" encoding =" UTF-8" ?>
362+ <container xmlns =" http://symfony.com/schema/dic/services"
363+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
364+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
365+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
334366
335- <!-- ... -->
367+ <imports >
368+ <import resource =" bundles/" />
369+ <import resource =" services/" />
370+ </imports >
371+
372+ <!-- ... -->
373+ </container >
336374
337375 .. code-block :: php
338376
@@ -343,39 +381,46 @@ by loading an entire directory:
343381 // ...
344382
345383
346- The Config component will look for recursively in the ``bundles/ `` and ``services/ ``
384+ The Config component will recursively look in the ``bundles/ `` and ``services/ ``
347385directories and it will load any supported file format (``.yml ``, ``.xml ``,
348386``.php ``, ``.ini ``).
349387
350388Global Configuration Files
351389~~~~~~~~~~~~~~~~~~~~~~~~~~
352390
353- Some system administrators may prefer to store sensitive parameteres in global
354- configuration files under the `` /etc `` directory. Imagine that the database
355- credentials for your website are stored in the ``/etc/sites/mysite.com/parameters.yml ``.
356- Loading this file is as simple as indicating the full file path when importing
357- it from any other configuration file:
391+ Some system administrators may prefer to store sensitive parameters in files
392+ outside the project directory. Imagine that the database credentials for your
393+ website are stored in the ``/etc/sites/mysite.com/parameters.yml ``. Loading this
394+ file is as simple as indicating the full file path when importing it from any
395+ other configuration file:
358396
359397.. configuration-block ::
360398
361399 .. code-block :: yaml
362400
363401 # app/config/config.yml
364402 imports :
365- - { resource: 'parameters.yml' }
366- - { resource: '/etc/sites/mysite.com/parameters.yml' }
403+ - { resource: 'parameters.yml' }
404+ - { resource: '/etc/sites/mysite.com/parameters.yml' }
367405
368406 # ...
369407
370408 .. code-block :: xml
371409
372- <!-- # app/config/config.xml -->
373- <imports >
374- <import resource =" parameters.yml" />
375- <import resource =" /etc/sites/mysite.com/parameters.yml" />
376- </imports >
410+ <!-- app/config/config.xml -->
411+ <?xml version =" 1.0" encoding =" UTF-8" ?>
412+ <container xmlns =" http://symfony.com/schema/dic/services"
413+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
414+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
415+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
377416
378- <!-- ... -->
417+ <imports >
418+ <import resource =" parameters.yml" />
419+ <import resource =" /etc/sites/mysite.com/parameters.yml" />
420+ </imports >
421+
422+ <!-- ... -->
423+ </container >
379424
380425 .. code-block :: php
381426
@@ -385,7 +430,7 @@ it from any other configuration file:
385430
386431 // ...
387432
388- Most of the time, local developers won't have the same files that exist in the
433+ Most of the time, local developers won't have the same files that exist on the
389434production servers. For that reason, the Config component provides the
390435``ignore_errors `` option to silently discard errors when the loaded file
391436doesn't exist:
@@ -396,20 +441,27 @@ doesn't exist:
396441
397442 # app/config/config.yml
398443 imports :
399- - { resource: 'parameters.yml' }
400- - { resource: '/etc/sites/mysite.com/parameters.yml', ignore_errors: true }
444+ - { resource: 'parameters.yml' }
445+ - { resource: '/etc/sites/mysite.com/parameters.yml', ignore_errors: true }
401446
402447 # ...
403448
404449 .. code-block :: xml
405450
406- <!-- # app/config/config.xml -->
407- <imports >
408- <import resource =" parameters.yml" />
409- <import resource =" /etc/sites/mysite.com/parameters.yml" ignore-errors =" true" />
410- </imports >
451+ <!-- app/config/config.xml -->
452+ <?xml version =" 1.0" encoding =" UTF-8" ?>
453+ <container xmlns =" http://symfony.com/schema/dic/services"
454+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
455+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
456+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
411457
412- <!-- ... -->
458+ <imports >
459+ <import resource =" parameters.yml" />
460+ <import resource =" /etc/sites/mysite.com/parameters.yml" ignore-errors =" true" />
461+ </imports >
462+
463+ <!-- ... -->
464+ </container >
413465
414466 .. code-block :: php
415467
0 commit comments