You are browsing the documentation for Symfony 2.5 which is not maintained anymore.
Consider upgrading your projects to Symfony 5.3.
The Debug Component
The Debug Component¶
The Debug component provides tools to ease debugging PHP code.
New in version 2.3: The Debug component was introduced in Symfony 2.3. Previously, the classes were located in the HttpKernel component.
You can install the component in many different ways:
The Debug component provides several tools to help you debug PHP code. Enabling them all is as easy as it can get:
use Symfony\Component\Debug\Debug; Debug::enable();
Read the following sections for more information about the different available tools.
You should never enable the debug tools in a production environment as they might disclose sensitive information to the user.
Enabling the Error Handler¶
Symfony\Component\Debug\ErrorHandler class catches PHP errors
and converts them to exceptions (of class
Symfony\Component\Debug\Exception\FatalErrorException for PHP
use Symfony\Component\Debug\ErrorHandler; ErrorHandler::register();
Enabling the Exception Handler¶
Symfony\Component\Debug\ExceptionHandler class catches
uncaught PHP exceptions and converts them to a nice PHP response. It is useful
in debug mode to replace the default PHP/XDebug output with something prettier
and more useful:
use Symfony\Component\Debug\ExceptionHandler; ExceptionHandler::register();
If the HttpFoundation component is available, the handler uses a Symfony Response object; if not, it falls back to a regular PHP response.
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.