@@ -178,8 +178,13 @@ should be as few times as possible at the entry point to your application.
178
178
Setting Up the Container with Configuration Files
179
179
-------------------------------------------------
180
180
181
- As well as setting up the services using PHP as above you can also use configuration
182
- files. To do this you also need to install :doc: `the Config Component</components/config/introduction> `.
181
+ As well as setting up the services using PHP as above you can also use
182
+ configuration files. This allows you to use XML or Yaml to write the definitions
183
+ for the services rather than using PHP to define the services as in the above
184
+ examples. In anything but the smallest applications it make sense to organise
185
+ the service definitions by moving them out into one or more configuration files.
186
+ To do this you also need to install
187
+ :doc: `the Config Component</components/config/introduction> `.
183
188
184
189
Loading an XML config file::
185
190
@@ -206,7 +211,19 @@ Loading a YAML config file::
206
211
If you want to load YAML config files then you will also need to install
207
212
:doc: `The YAML component</components/yaml/introduction> `.
208
213
209
- The ``newsletter_manager `` and ``mailer `` services can be set up using config files:
214
+ If you do want to use PHP to create the services then you can move this
215
+ into a separate config file and load it in a similar way::
216
+
217
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
218
+ use Symfony\Component\Config\FileLocator;
219
+ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
220
+
221
+ $container = new ContainerBuilder();
222
+ $loader = new PhpFileLoader($container, new FileLocator(__DIR__));
223
+ $loader->load('services.php');
224
+
225
+ You can now set up the ``newsletter_manager `` and ``mailer `` services using
226
+ config files:
210
227
211
228
.. configuration-block ::
212
229
0 commit comments