@@ -67,7 +67,8 @@ readable. These are the main advantages and disadvantages of each format:
6767* **YAML **: simple, clean and readable, but not all IDEs support autocompletion
6868 and validation for it. :doc: `Learn the YAML syntax </reference/formats/yaml >`;
6969* **PHP **: very powerful and it allows you to create dynamic configuration with
70- arrays or a :ref: `ConfigBuilder <config-config-builder >`.
70+ arrays, and benefits from auto completion and static analysis using
71+ array shapes.
7172
7273Importing Configuration Files
7374~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -88,9 +89,9 @@ configuration files, even if they use a different format:
8889 - { resource: '/etc/myapp/*.yaml' }
8990
9091 # ignore_errors: not_found silently discards errors if the loaded file doesn't exist
91- - { resource: 'my_config_file.xml ', ignore_errors: not_found }
92+ - { resource: 'my_config_file.php ', ignore_errors: not_found }
9293 # ignore_errors: true silently discards all errors (including invalid code and not found)
93- - { resource: 'my_other_config_file.xml ', ignore_errors: true }
94+ - { resource: 'my_other_config_file.php ', ignore_errors: true }
9495
9596 # ...
9697
@@ -212,7 +213,11 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
212213 'email_address' => param('app.admin_email'),
213214
214215 // ... but if you prefer it, you can also pass the name as a string
216+ <<<<<<< HEAD
215217 // surrounded by two % (same as in YAML format) and Symfony will
218+ =======
219+ // surrounded by two % (same as in the YAML format) and Symfony will
220+ >>>>>>> 7.4
216221 // replace it by that parameter value
217222 'email_address' => '%app.admin_email%',
218223 ]);
@@ -1063,52 +1068,6 @@ parameters at once by type-hinting any of its constructor arguments with the
10631068 }
10641069 }
10651070
1066- .. _config-config-builder :
1067-
1068- Using PHP ConfigBuilders
1069- ------------------------
1070-
1071- Writing PHP config is sometimes difficult because you end up with large nested
1072- arrays and you have no autocompletion help from your favorite IDE. A way to
1073- address this is to use "ConfigBuilders". They are objects that will help you
1074- build these arrays.
1075-
1076- Symfony generates the ConfigBuilder classes automatically in the
1077- :ref: `kernel build directory <configuration-kernel-build-directory >` for all the
1078- bundles installed in your application. By convention they all live in the
1079- namespace ``Symfony\Config ``::
1080-
1081- // config/packages/security.php
1082- use Symfony\Config\SecurityConfig;
1083-
1084- return static function (SecurityConfig $security): void {
1085- $security->firewall('main')
1086- ->pattern('^/*')
1087- ->lazy(true)
1088- ->security(false);
1089-
1090- $security
1091- ->roleHierarchy('ROLE_ADMIN', ['ROLE_USER'])
1092- ->roleHierarchy('ROLE_SUPER_ADMIN', ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'])
1093- ->accessControl()
1094- ->path('^/user')
1095- ->roles('ROLE_USER');
1096-
1097- $security->accessControl(['path' => '^/admin', 'roles' => 'ROLE_ADMIN']);
1098- };
1099-
1100- .. note ::
1101-
1102- Only root classes in the namespace ``Symfony\Config `` are ConfigBuilders.
1103- Nested configs (e.g. ``\Symfony\Config\Framework\CacheConfig ``) are regular
1104- PHP objects which aren't autowired when using them as an argument type.
1105-
1106- .. note ::
1107-
1108- In order to get ConfigBuilders autocompletion in your IDE/editor, make sure
1109- to not exclude the directory where these classes are generated (by default,
1110- in ``var/cache/dev/Symfony/Config/ ``).
1111-
11121071Keep Going!
11131072-----------
11141073
0 commit comments