Skip to content

Commit 8a8251c

Browse files
committed
minor #20706 Add documentation for error:dump command (pyrech)
This PR was merged into the 7.3 branch. Discussion ---------- Add documentation for `error:dump` command <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Fix #20704 PR introducing the command: symfony/symfony#58769 Commits ------- d976d0e Add documentation for error:dump command
2 parents cd314b1 + d976d0e commit 8a8251c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

controller/error_pages.rst

+46
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,49 @@ time and again, you can have just one (or several) listeners deal with them.
336336
your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`)
337337
and takes measures like redirecting the user to the login page, logging them
338338
out and other things.
339+
340+
Dumping error pages in static HTML files
341+
----------------------------------------
342+
343+
When a web server cannot handle a request or when it triggers an error without
344+
calling the PHP application, it will return its default error pages, instead of
345+
rendering the errors as defined in your application (whether it's Symfony's
346+
default "Oops" error page or the pages you customized in your application).
347+
348+
To avoid that and always have your web server rendering your application's error
349+
pages, you can dump each HTTP status error in a their own static HTML files:
350+
351+
.. code-block:: terminal
352+
353+
$ php bin/console error:dump [--force] var/cache/prod/error_pages
354+
355+
.. note::
356+
357+
By default, it will dump HTML files for each HTTP status error.
358+
You can restrict that to dump only some HTTP status code by passing them as
359+
in the second argument of the command.
360+
361+
Once the static pages are generated, you can now configure your web server to use
362+
them instead of their default error page. Here is an example configuration with
363+
nginx:
364+
365+
.. code-block:: nginx
366+
367+
# /etc/nginx/conf.d/example.com.conf
368+
server {
369+
# Your existing serverconfiguration
370+
# ...
371+
372+
373+
# Configure nginx to serve your application's error pages
374+
error_page 400 /error_pages/400.html;
375+
error_page 401 /error_pages/401.html;
376+
# ...
377+
error_page 510 /error_pages/510.html;
378+
error_page 511 /error_pages/511.html;
379+
380+
location ^~ /error_pages/ {
381+
root /path/to/your/symfony/var/cache/error_pages;
382+
internal; # allows this location block to not be triggered when a user manually call these /error_pages/.* urls
383+
}
384+
}

0 commit comments

Comments
 (0)