@@ -53,7 +53,7 @@ Configuration Formats
5353~~~~~~~~~~~~~~~~~~~~~ 
5454
5555Unlike other frameworks, Symfony doesn't impose a specific format on you to
56- configure your applications, but lets you choose between YAML, XML  and PHP.
56+ configure your applications, but lets you choose between YAML and PHP.
5757Throughout the Symfony documentation, all configuration examples will be
5858shown in these three formats.
5959
@@ -66,20 +66,18 @@ readable. These are the main advantages and disadvantages of each format:
6666
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 >`;
69- * **XML **: autocompleted/validated by most IDEs and is parsed natively by PHP,
70-   but sometimes it generates configuration considered too verbose. `Learn the XML syntax `_;
7169* **PHP **: very powerful and it allows you to create dynamic configuration with
72-   arrays or a :ref: `ConfigBuilder  <config-config-builder >`.
70+   arrays, and benefits from auto completion and static analysis using
71+   array shapes.
7372
74- .. note ::
73+ .. deprecated :: 7.4 
74+ 
75+     The XML and Config Builder formats are deprecated in Symfony 7.4 and
76+     will be removed in Symfony 8.0.
7577
76-     By default Symfony loads the configuration files defined in YAML and PHP
77-     formats. If you define configuration in XML format, update the
78-     :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Kernel\\ MicroKernelTrait::configureContainer `
79-     and/or
80-     :method: `Symfony\\ Bundle\\ FrameworkBundle\\ Kernel\\ MicroKernelTrait::configureRoutes `
81-     methods in the ``src/Kernel.php `` file to add support for the ``.xml `` file
82-     extension.
78+ .. versionadded :: 7.4 
79+ 
80+     Array shapes were introduced in Symfony 7.4.
8381
8482Importing Configuration Files
8583~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
@@ -100,9 +98,9 @@ configuration files, even if they use a different format:
10098            - { resource: '/etc/myapp/*.yaml' }  
10199
102100            #  ignore_errors: not_found silently discards errors if the loaded file doesn't exist 
103-             - { resource: 'my_config_file.xml ', ignore_errors: not_found }  
101+             - { resource: 'my_config_file.php ', ignore_errors: not_found }  
104102            #  ignore_errors: true silently discards all errors (including invalid code and not found) 
105-             - { resource: 'my_other_config_file.xml ', ignore_errors: true }  
103+             - { resource: 'my_other_config_file.php ', ignore_errors: true }  
106104
107105        #  ... 
108106
@@ -267,27 +265,6 @@ reusable configuration value. By convention, parameters are defined under the
267265
268266        // ... 
269267
270-  .. warning ::
271- 
272-     By default and when using XML configuration, the values between ``<parameter> ``
273-     tags are not trimmed. This means that the value of the following parameter will be
274- 275- 
276-     .. code-block :: xml 
277- 
278-         <parameter  key =" app.admin_email"  > 
279- 280-         </parameter > 
281- 
282-      If you want to trim the value of your parameter, use the ``trim `` attribute.
283-     When using it, the value of the following parameter will be ``
[email protected] ``:
284- 
285-     .. code-block :: xml 
286- 
287-         <parameter  key =" app.admin_email"   trim =" true"  > 
288- 289-         </parameter > 
290- 
291268 Once defined, you can reference this parameter value from any other
292269configuration file using a special syntax: wrap the parameter name in two ``% ``
293270(e.g. ``%app.admin_email% ``):
@@ -331,7 +308,7 @@ configuration file using a special syntax: wrap the parameter name in two ``%``
331308                'email_address' => param('app.admin_email'), 
332309
333310                // ... but if you prefer it, you can also pass the name as a string 
334-                 // surrounded by two % (same as in YAML and XML formats ) and Symfony will 
311+                 // surrounded by two % (same as in the  YAML format ) and Symfony will 
335312                // replace it by that parameter value 
336313                'email_address' => '%app.admin_email%', 
337314            ]); 
@@ -1302,52 +1279,6 @@ parameters at once by type-hinting any of its constructor arguments with the
13021279        } 
13031280    } 
13041281
1305- .. _config-config-builder :
1306- 
1307- Using PHP ConfigBuilders
1308- ------------------------ 
1309- 
1310- Writing PHP config is sometimes difficult because you end up with large nested
1311- arrays and you have no autocompletion help from your favorite IDE. A way to
1312- address this is to use "ConfigBuilders". They are objects that will help you
1313- build these arrays.
1314- 
1315- Symfony generates the ConfigBuilder classes automatically in the
1316- :ref: `kernel build directory  <configuration-kernel-build-directory >` for all the
1317- bundles installed in your application. By convention they all live in the
1318- namespace ``Symfony\Config ``::
1319- 
1320-     // config/packages/security.php 
1321-     use Symfony\Config\SecurityConfig; 
1322- 
1323-     return static function (SecurityConfig $security): void { 
1324-         $security->firewall('main') 
1325-             ->pattern('^/*') 
1326-             ->lazy(true) 
1327-             ->security(false); 
1328- 
1329-         $security 
1330-             ->roleHierarchy('ROLE_ADMIN', ['ROLE_USER']) 
1331-             ->roleHierarchy('ROLE_SUPER_ADMIN', ['ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH']) 
1332-             ->accessControl() 
1333-                 ->path('^/user') 
1334-                 ->roles('ROLE_USER'); 
1335- 
1336-         $security->accessControl(['path' => '^/admin', 'roles' => 'ROLE_ADMIN']); 
1337-     }; 
1338- 
1339- .. note ::
1340- 
1341-     Only root classes in the namespace ``Symfony\Config `` are ConfigBuilders.
1342-     Nested configs (e.g. ``\Symfony\Config\Framework\CacheConfig ``) are regular
1343-     PHP objects which aren't autowired when using them as an argument type.
1344- 
1345- .. note ::
1346- 
1347-     In order to get ConfigBuilders autocompletion in your IDE/editor, make sure
1348-     to not exclude the directory where these classes are generated (by default,
1349-     in ``var/cache/dev/Symfony/Config/ ``).
1350- 
13511282Keep Going!
13521283----------- 
13531284
@@ -1369,7 +1300,6 @@ And all the other topics related to configuration:
13691300
13701301    configuration/*  
13711302
1372- .. _`Learn the XML syntax` : https://en.wikipedia.org/wiki/XML 
13731303.. _`environment variables` : https://en.wikipedia.org/wiki/Environment_variable 
13741304.. _`symbolic links` : https://en.wikipedia.org/wiki/Symbolic_link 
13751305.. _`utilities to manage env vars` : https://symfony.com/doc/current/cloud/env.html 
0 commit comments