From df35697260d77bc6910818aea7654bf1923b6126 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 7 Apr 2013 18:08:21 +0200 Subject: [PATCH] added documentation for the new Debug component --- components/debug.rst | 75 ++++++++++++++++++++++++++++++++++++++++++ components/index.rst | 1 + components/map.rst.inc | 4 +++ 3 files changed, 80 insertions(+) create mode 100644 components/debug.rst diff --git a/components/debug.rst b/components/debug.rst new file mode 100644 index 00000000000..94f21514550 --- /dev/null +++ b/components/debug.rst @@ -0,0 +1,75 @@ +.. index:: + single: Debug + single: Components; Debug + +The Debug Component +=================== + + The Debug Component provides tools to ease debugging PHP code. + +.. versionadded:: 2.3 + The Debug Component is new to Symfony 2.3. Previously, the classes were + located in the ``HttpKernel`` component. + +Installation +------------ + +You can install the component in many different ways: + +* Use the official Git repository (https://github.com/symfony/Debug); +* :doc:`Install it via Composer ` (``symfony/debug`` on `Packagist`_). + +Usage +----- + +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(); + +The :method:`Symfony\\Component\\Debug\\Debug::enable` method registers an +error handler and an exception handler. If the :doc:`ClassLoader component +` is available, a special class loader is also +registered. + +Read the following sections for more information about the different available +tools. + +.. caution:: + + You should never enable the debug tools in a production environment as + they might disclose sensitive information to the user. + +Enabling the Error Handler +-------------------------- + +The :class:`Symfony\\Component\\Debug\\ErrorHandler` class catches PHP errors +and converts them to exceptions (of class :phpclass:`ErrorException` or +:class:`Symfony\\Component\\Debug\\Exception\\FatalErrorException` for PHP +fatal errors):: + + use Symfony\Component\Debug\ErrorHandler; + + ErrorHandler::register(); + +Enabling the Exception Handler +------------------------------ + +The :class:`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(); + +.. note:: + + If the :doc:`HttpFoundation component ` is + available, the handler uses a Symfony Response object; if not, it falls + back to a regular PHP response. + +.. _Packagist: https://packagist.org/packages/symfony/debug diff --git a/components/index.rst b/components/index.rst index 8b4abe24f8d..8f9b989cd11 100644 --- a/components/index.rst +++ b/components/index.rst @@ -9,6 +9,7 @@ The Components config/index console/index css_selector + debug dom_crawler dependency_injection/index event_dispatcher/index diff --git a/components/map.rst.inc b/components/map.rst.inc index f16a8e874b2..e2a0d317eb2 100644 --- a/components/map.rst.inc +++ b/components/map.rst.inc @@ -23,6 +23,10 @@ * :doc:`/components/css_selector` +* **Debug** + + * :doc:`/components/debug` + * :doc:`/components/dependency_injection/index` * :doc:`/components/dependency_injection/introduction`