Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Add documentation forerror:dump
command#20706
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. wdyt adding a doc forfrankenphp ? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
} |