Warning: You are browsing the documentation for Symfony 2.8, which is no longer maintained.
Read the updated version of this page for Symfony 6.0 (the current stable version).
Table of Contents
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.
$ composer require symfony/debug
Alternatively, you can clone the https://github.com/symfony/debug repository.
If you install this component outside of a Symfony application, you must
vendor/autoload.php file in your code to enable the class
autoloading mechanism provided by Composer. Read
this article for more details.
The Debug component provides several tools to help you debug PHP code. Enabling them all is as easy as it can get:
1 2 3
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.
1 2 3
use Symfony\Component\Debug\ErrorHandler; ErrorHandler::register();
The 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:
1 2 3
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.
The DebugClassLoader attempts to
throw more helpful exceptions when a class isn't found by the registered
autoloaders. All autoloaders that implement a
findFile() method are replaced
DebugClassLoader is as easy as calling its static
1 2 3
use Symfony\Component\Debug\DebugClassLoader; DebugClassLoader::enable();