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