@@ -141,7 +141,7 @@ when importing it from any other configuration file:
141
141
142
142
# config/services.yaml
143
143
imports :
144
- - { resource: '/etc/sites/mysite.com/parameters.yaml', ignore_errors : true }
144
+ - { resource: '/etc/sites/mysite.com/parameters.yaml', ignore_not_found : true }
145
145
146
146
# ...
147
147
@@ -157,7 +157,7 @@ when importing it from any other configuration file:
157
157
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
158
158
159
159
<imports >
160
- <import resource =" /etc/sites/mysite.com/parameters.yaml" ignore-errors =" true" />
160
+ <import resource =" /etc/sites/mysite.com/parameters.yaml" ignore-not-found =" true" />
161
161
</imports >
162
162
163
163
<!-- ... -->
@@ -166,17 +166,63 @@ when importing it from any other configuration file:
166
166
.. code-block :: php
167
167
168
168
// config/services.php
169
- $loader->import('/etc/sites/mysite.com/parameters.yaml', null, true);
169
+ use Symfony\Component\Config\Loader\FileLoader;
170
+
171
+ $loader->import('/etc/sites/mysite.com/parameters.yaml', null, FileLoader::IGNORE_FILE_NOT_FOUND);
170
172
171
173
// ...
172
174
175
+ .. versionadded :: 4.4
176
+
177
+ The ``ignore_not_found `` option was introduced in Symfony 4.4.
178
+
173
179
.. tip ::
174
180
175
- The ``ignore_errors `` option (which is the third optional argument in the
181
+ The ``ignore_not_found `` option (which is the third optional argument in the
176
182
loader's ``import() `` method) silently discards errors when the loaded file
177
183
doesn't exist. This is needed in this case because most of the time, local
178
184
developers won't have the same files that exist on the production servers.
179
185
186
+ The older ``ignore_errors `` option silently discards all errors when the loaded file
187
+ doesn't exist or contains invalid code.
188
+
189
+ .. configuration-block ::
190
+
191
+ .. code-block :: yaml
192
+
193
+ # config/services.yaml
194
+ imports :
195
+ - { resource: '/etc/sites/mysite.com/parameters.yaml', ignore_errors: true }
196
+
197
+ # ...
198
+
199
+ .. code-block :: xml
200
+
201
+ <!-- config/services.xml -->
202
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
203
+ <container xmlns =" http://symfony.com/schema/dic/services"
204
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
205
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
206
+ https://symfony.com/schema/dic/services/services-1.0.xsd
207
+ http://symfony.com/schema/dic/symfony
208
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
209
+
210
+ <imports >
211
+ <import resource =" /etc/sites/mysite.com/parameters.yaml" ignore-errors =" true" />
212
+ </imports >
213
+
214
+ <!-- ... -->
215
+ </container >
216
+
217
+ .. code-block :: php
218
+
219
+ // config/services.php
220
+ use Symfony\Component\Config\Loader\FileLoader;
221
+
222
+ $loader->import('/etc/sites/mysite.com/parameters.yaml', null, FileLoader::IGNORE_ALL);
223
+
224
+ // ...
225
+
180
226
As you've seen, there are lots of ways to organize your configuration files. You
181
227
can choose one of these or even create your own custom way of organizing the
182
228
files. For even more customization, see ":doc: `/configuration/override_dir_structure `".
0 commit comments