Skip to content

Commit 8e434a7

Browse files
committed
minor #16728 [Routing] Fix path/example content of error route files (maartendekeizer)
This PR was merged into the 5.4 branch. Discussion ---------- [Routing] Fix path/example content of error route files Removed `dev` part from file location, adjusted code example. Recipes of framework bundle don't include `config/routes/dev/framework.yaml` file anymore but use `when@dev` block in `config/routes/framework.yaml` Commits ------- 3a52f56 Fix path/example content of error route files
2 parents 8c21b7b + 3a52f56 commit 8e434a7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

controller/error_pages.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,37 @@ automatically when installing ``symfony/framework-bundle``):
155155

156156
.. code-block:: yaml
157157
158-
# config/routes/dev/framework.yaml
159-
_errors:
160-
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
161-
prefix: /_error
158+
# config/routes/framework.yaml
159+
when@dev:
160+
_errors:
161+
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
162+
prefix: /_error
162163
163164
.. code-block:: xml
164165
165-
<!-- config/routes/dev/framework.xml -->
166+
<!-- config/routes/framework.xml -->
166167
<?xml version="1.0" encoding="UTF-8" ?>
167168
<routes xmlns="http://symfony.com/schema/routing"
168169
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
169170
xsi:schemaLocation="http://symfony.com/schema/routing
170171
https://symfony.com/schema/routing/routing-1.0.xsd">
171172
172-
<import resource="@FrameworkBundle/Resources/config/routing/errors.xml" prefix="/_error"/>
173+
<when env="prod">
174+
<import resource="@FrameworkBundle/Resources/config/routing/errors.xml" prefix="/_error"/>
175+
</when>
173176
</routes>
174177
175178
.. code-block:: php
176179
177-
// config/routes/dev/framework.php
180+
// config/routes/framework.php
178181
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
179182
180183
return function (RoutingConfigurator $routes) {
181-
$routes->import('@FrameworkBundle/Resources/config/routing/errors.xml')
182-
->prefix('/_error')
183-
;
184+
if ('dev' === $container->env()) {
185+
$routes->import('@FrameworkBundle/Resources/config/routing/errors.xml')
186+
->prefix('/_error')
187+
;
188+
}
184189
};
185190
186191
With this route added, you can use URLs like these to preview the *error* page

0 commit comments

Comments
 (0)