Skip to content

Commit 62bcb4e

Browse files
committed
minor #21516 Remove mentions of XML and Config Builders in Getting started guides (wouterj)
This PR was merged into the 7.4 branch. Discussion ---------- Remove mentions of XML and Config Builders in Getting started guides XML is deprecated in 7.4. We should not advocate it anymore and people are on their own when they wish to still use it. For now, I suggest keeping the code examples (except from the Quick tour) to help in migration and developers inheriting apps using XML. Commits ------- 64c30da Remove mentions of XML and Config Builders in Getting started guides
2 parents 7cb6fac + 64c30da commit 62bcb4e

File tree

5 files changed

+22
-112
lines changed

5 files changed

+22
-112
lines changed

configuration.rst

Lines changed: 13 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Configuration Formats
5353
~~~~~~~~~~~~~~~~~~~~~
5454

5555
Unlike 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.
5757
Throughout the Symfony documentation, all configuration examples will be
5858
shown 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

8482
Importing 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-
``'\n something@example.com\n'``:
275-
276-
.. code-block:: xml
277-
278-
<parameter key="app.admin_email">
279-
something@example.com
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 ``something@example.com``:
284-
285-
.. code-block:: xml
286-
287-
<parameter key="app.admin_email" trim="true">
288-
something@example.com
289-
</parameter>
290-
291268
Once defined, you can reference this parameter value from any other
292269
configuration 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-
13511282
Keep 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

page_creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ try it out by going to: http://localhost:8000/lucky/number
8787

8888
Symfony recommends defining routes as attributes to have the controller code
8989
and its route configuration at the same location. However, if you prefer, you can
90-
:doc:`define routes in separate files </routing>` using YAML, XML and PHP formats.
90+
:doc:`define routes in separate files </routing>` using the YAML or PHP formats.
9191

9292
If you see a lucky number being printed back to you, congratulations! But before
9393
you run off to play the lottery, check out how this works. Remember the two steps

quick_tour/the_architecture.rst

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -243,29 +243,6 @@ using the special ``when@`` keyword:
243243
router:
244244
strict_requirements: null
245245
246-
.. code-block:: xml
247-
248-
<!-- config/packages/framework.xml -->
249-
<?xml version="1.0" encoding="UTF-8" ?>
250-
<container xmlns="http://symfony.com/schema/dic/services"
251-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
252-
xmlns:framework="http://symfony.com/schema/dic/symfony"
253-
xsi:schemaLocation="http://symfony.com/schema/dic/services
254-
https://symfony.com/schema/dic/services/services-1.0.xsd
255-
http://symfony.com/schema/dic/symfony
256-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
257-
258-
<framework:config>
259-
<framework:router utf8="true"/>
260-
</framework:config>
261-
262-
<when env="prod">
263-
<framework:config>
264-
<framework:router strict-requirements="null"/>
265-
</framework:config>
266-
</when>
267-
</container>
268-
269246
.. code-block:: php
270247
271248
// config/packages/framework.php

routing.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ provides other useful features, like generating SEO-friendly URLs (e.g.
1212
Creating Routes
1313
---------------
1414

15-
Routes can be configured in YAML, XML, PHP or using attributes.
16-
All formats provide the same features and performance, so choose
17-
your favorite.
15+
Routes can be configured in YAML, PHP or using attributes. All formats
16+
provide the same features and performance, so choose your favorite.
1817
:ref:`Symfony recommends attributes <best-practice-controller-attributes>`
1918
because it's convenient to put the route and controller in the same place.
2019

20+
.. deprecated:: 7.4
21+
22+
The XML format to configure routes is deprecated in Symfony 7.4 and
23+
will be removed in Symfony 8.0.
24+
2125
.. _routing-route-attributes:
2226

2327
Creating Routes as Attributes

service_container.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,7 @@ all their types (string, boolean, array, binary and PHP constant parameters).
704704

705705
However, there is another type of parameter related to services. In YAML config,
706706
any string which starts with ``@`` is considered as the ID of a service, instead
707-
of a regular string. In XML config, use the ``type="service"`` type for the
708-
parameter and in PHP config use the ``service()`` function:
707+
of a regular string. In PHP config use the ``service()`` function:
709708

710709
.. configuration-block::
711710

0 commit comments

Comments
 (0)