Skip to content

Commit 0a6873d

Browse files
pulzarraiderwouterj
authored andcommitted
[Configuration] Add documentation about ignore_errors: not_found option.
1 parent 8a7d32e commit 0a6873d

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

configuration.rst

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ configuration files, even if they use a different format:
8888
# config/services.yaml
8989
imports:
9090
- { resource: 'legacy_config.php' }
91-
# ignore_errors silently discards errors if the loaded file doesn't exist
92-
- { resource: 'my_config_file.xml', ignore_errors: true }
91+
9392
# glob expressions are also supported to load multiple files
9493
- { resource: '/etc/myapp/*.yaml' }
9594
95+
# ignore_errors: not_found silently discards errors if the loaded file doesn't exist
96+
- { resource: 'my_config_file.xml', ignore_errors: not_found }
97+
# ignore_errors: true silently discards all errors (including invalid code and not found)
98+
- { resource: 'my_other_config_file.xml', ignore_errors: true }
99+
96100
# ...
97101
98102
.. code-block:: xml
@@ -108,10 +112,13 @@ configuration files, even if they use a different format:
108112
109113
<imports>
110114
<import resource="legacy_config.php"/>
111-
<!-- ignore_errors silently discards errors if the loaded file doesn't exist -->
112-
<import resource="my_config_file.yaml" ignore-errors="true"/>
113115
<!-- glob expressions are also supported to load multiple files -->
114116
<import resource="/etc/myapp/*.yaml"/>
117+
118+
<!-- ignore-errors="not_found" silently discards errors if the loaded file doesn't exist -->
119+
<import resource="my_config_file.yaml" ignore-errors="not_found"/>
120+
<!-- ignore-errors="true" silently discards all errors (including invalid code and not found) -->
121+
<import resource="my_other_config_file.yaml" ignore-errors="true"/>
115122
</imports>
116123
117124
<!-- ... -->
@@ -124,14 +131,23 @@ configuration files, even if they use a different format:
124131
125132
return static function (ContainerConfigurator $container) {
126133
$container->import('legacy_config.php');
127-
// ignore_errors (3rd parameter) silently discards errors if the loaded file doesn't exist
128-
$container->import('my_config_file.xml', null, true);
134+
129135
// glob expressions are also supported to load multiple files
130136
$container->import('/etc/myapp/*.yaml');
137+
138+
// the third optional argument of import() is 'ignore_errors'
139+
// 'ignore_errors' set to 'not_found' silently discards errors if the loaded file doesn't exist
140+
$container->import('my_config_file.yaml', null, 'not_found');
141+
// 'ignore_errors' set to true silently discards all errors (including invalid code and not found)
142+
$container->import('my_config_file.yaml', null, true);
131143
};
132144
133145
// ...
134146
147+
.. versionadded:: 4.4
148+
149+
The ``not_found`` option value for ``ignore_errors`` was introduced in Symfony 4.4.
150+
135151
.. _config-parameter-intro:
136152
.. _config-parameters-yml:
137153
.. _configuration-parameters:

0 commit comments

Comments
 (0)