Skip to content
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

Add documentation for error:dump command #20706

Merged
merged 1 commit into from
Mar 10, 2025
Merged
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
46 changes: 46 additions & 0 deletions controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,49 @@ time and again, you can have just one (or several) listeners deal with them.
your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`)
and takes measures like redirecting the user to the login page, logging them
out and other things.

Dumping error pages in static HTML files
----------------------------------------

When a web server cannot handle a request or when it triggers an error without
calling the PHP application, it will return its default error pages, instead of
rendering the errors as defined in your application (whether it's Symfony's
default "Oops" error page or the pages you customized in your application).

To avoid that and always have your web server rendering your application's error
pages, you can dump each HTTP status error in a their own static HTML files:

.. code-block:: terminal

$ php bin/console error:dump [--force] var/cache/prod/error_pages

.. note::

By default, it will dump HTML files for each HTTP status error.
You can restrict that to dump only some HTTP status code by passing them as
in the second argument of the command.

Once the static pages are generated, you can now configure your web server to use
them instead of their default error page. Here is an example configuration with
nginx:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt adding a doc for frankenphp ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use Frankenphp, so feel free to suggest a working configuration for it (or for any other web server) 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add new config formats in future PRs if folks contribute them. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will try to when I upgrade to v7.3, bookmarking this comments flows


.. code-block:: nginx

# /etc/nginx/conf.d/example.com.conf
server {
# Your existing serverconfiguration
# ...


# Configure nginx to serve your application's error pages
error_page 400 /error_pages/400.html;
error_page 401 /error_pages/401.html;
# ...
error_page 510 /error_pages/510.html;
error_page 511 /error_pages/511.html;

location ^~ /error_pages/ {
root /path/to/your/symfony/var/cache/error_pages;
internal; # allows this location block to not be triggered when a user manually call these /error_pages/.* urls
}
}