Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Development of custom error pages is impractical if you need to set kernel.debug=false#3577

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mpdude wants to merge4 commits intosymfony:masterfromwebfactory:add-note-exceptions-bundle
Closed
Changes fromall 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
23 changes: 21 additions & 2 deletionscookbook/controller/error_pages.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,13 +29,30 @@ control you need:
which allows complete control over exception handling. For more
information, see :ref:`kernel-kernel.exception`.

The default ``ExceptionController`` will either display an
*exception* or *error* page, depending on the setting of the ``kernel.debug``
flag. While *exception* pages give you a lot of helpful
information during development, *error* pages are meant to be
shown to the end-user.

.. sidebar:: Testing Error Pages during Development

You should not set ``kernel.debug`` to ``false`` in order to see your
error pages during development. This will also stop
Symfony2 from recompiling your twig templates, among other things.

The third-party `WebfactoryExceptionsBundle`_ provides a special
test controller that allows you to display your custom error
pages for arbitrary HTTP status codes even with
``kernel.debug`` set to ``true``.

All of the error templates live inside the TwigBundle. To override the
templates, simply rely on the standard method for overriding templates that
live inside a bundle. For more information, see
:ref:`overriding-bundle-templates`.

For example, to override the default error template that's shown to the
end-user, create a newtemplate located at
For example, to override the default error template, create a new
template located at
``app/Resources/TwigBundle/views/Exception/error.html.twig``:

.. code-block:: html+jinja
Expand DownExpand Up@@ -110,3 +127,5 @@ Symfony uses the following algorithm to determine which template to use:
customized in the same way by creating templates such as
``exception.html.twig`` for the standard HTML exception page or
``exception.json.twig`` for the JSON exception page.

.. _`WebfactoryExceptionsBundle`: https://github.com/webfactory/exceptions-bundle

[8]ページ先頭

©2009-2025 Movatter.jp