Add PHP config support for routing

This commit is contained in:
Antoine Lamirault
2025-04-28 12:10:49 +02:00
parent 5147f15cb9
commit 40a99acbbe
2 changed files with 17 additions and 5 deletions

View File

@@ -297,8 +297,8 @@ Now it looks like this::
{
// import the WebProfilerRoutes, only if the bundle is enabled
if (isset($this->bundles['WebProfilerBundle'])) {
$routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml')->prefix('/_wdt');
$routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml')->prefix('/_profiler');
$routes->import('@WebProfilerBundle/Resources/config/routing/wdt.php', 'php')->prefix('/_wdt');
$routes->import('@WebProfilerBundle/Resources/config/routing/profiler.php', 'php')->prefix('/_profiler');
}
// load the routes defined as PHP attributes
@@ -310,6 +310,12 @@ Now it looks like this::
// to override the default locations for these directories
}
.. versionadded:: 7.3
The ``wdt.php`` and ``profiler.php`` files were introduced in Symfony 7.3.
Previously, you had to import ``wdt.xml`` and ``profiler.xml``
Before continuing, run this command to add support for the new dependencies:
.. code-block:: terminal

View File

@@ -154,7 +154,8 @@ automatically when installing ``symfony/framework-bundle``):
# config/routes/framework.yaml
when@dev:
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
resource: '@FrameworkBundle/Resources/config/routing/errors.php'
type: php
prefix: /_error
.. code-block:: xml
@@ -167,7 +168,7 @@ automatically when installing ``symfony/framework-bundle``):
https://symfony.com/schema/routing/routing-1.0.xsd">
<when env="dev">
<import resource="@FrameworkBundle/Resources/config/routing/errors.xml" prefix="/_error"/>
<import resource="@FrameworkBundle/Resources/config/routing/errors.php" type="php" prefix="/_error"/>
</when>
</routes>
@@ -178,7 +179,7 @@ automatically when installing ``symfony/framework-bundle``):
return function (RoutingConfigurator $routes): void {
if ('dev' === $routes->env()) {
$routes->import('@FrameworkBundle/Resources/config/routing/errors.xml')
$routes->import('@FrameworkBundle/Resources/config/routing/errors.php', 'php')
->prefix('/_error')
;
}
@@ -191,6 +192,11 @@ need to replace ``http://localhost/`` by the host used in your local setup):
* ``http://localhost/_error/{statusCode}`` for HTML
* ``http://localhost/_error/{statusCode}.{format}`` for any other format
.. versionadded:: 7.3
The ``errors.php`` file was introduced in Symfony 7.3.
Previously, you had to import ``errors.xml``
.. _overriding-non-html-error-output:
Overriding Error output for non-HTML formats