Home / Symfony / New in Symfony 7.4: Better Exceptions in Terminal

New in Symfony 7.4: Better Exceptions in Terminal


Yonel Ceruto
Contributed by
Yonel Ceruto
in
#60033

When running Symfony applications in debug mode, exceptions are displayed in
a rich debugging page in your browser, with full stack traces and helpful tools
to diagnose issues instantly:

Symfony exception page shown in browsers

However, that same HTML output has always been shown in the console whenever an
exception occurred (e.g. when running tests). Instead of a clean, readable
exception message, you’d get hundreds of lines of HTML, CSS, and JavaScript
flooding your terminal:

Symfony exception showing full HTML contents when running tests in terminal

This has long been one of the most frustrating parts of the Symfony testing
experience. Previous versions tried to ease the pain by adding the main
exception message inside HTML comments at the top and bottom of the output.

In Symfony 7.4, this is finally fixed. Exceptions are now displayed as clean,
readable stack traces in the terminal
, just like you’d expect:

Symfony exception showing a readable plain text trace in terminal starting in Symfony 7.4

Symfony 7.4 automatically selects the appropriate error renderer depending on
your runtime environment. Technically, it uses the value of the
kernel.runtime_mode option to decide when to render the error as HTML and
when as plain text.

This value is automatically set based on the execution context, but you can
also control it explicitly by setting the APP_RUNTIME_MODE environment
variable.


Sponsor the Symfony project.
Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *