Skip to content

Add PHP config support for routing #20923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions configuration/micro_kernel_trait.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>

Expand All @@ -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')
;
}
Expand All @@ -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
Expand Down