Skip to content

added documentation for the new Debug component #2479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions components/debug.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.. index::
single: Debug
single: Components; Debug

The Debug Component
===================

The Debug Component provides tools to ease debugging PHP code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add the note saying it is new in 2.3, extracting code from HttpKernel (see how it is done for PropertyAccess)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


.. 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 </components/using_components>` (``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
</components/class_loader>` is available, a special class loader is also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to have rules on 1 line:

[...] If the
:doc:`ClassLoader component </components/class_loader>` is available,
a special [...]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not what we are doing elsewhere. I don't format things by hand but via my text editor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something I always say on PRs and it's something that's done in all documents as far as I can see.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will let you reformat what you think is best.

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 </components/http_foundation>` 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
1 change: 1 addition & 0 deletions components/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The Components
config/index
console/index
css_selector
debug
dom_crawler
dependency_injection/index
event_dispatcher/index
Expand Down
4 changes: 4 additions & 0 deletions components/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

* :doc:`/components/css_selector`

* **Debug**

* :doc:`/components/debug`

* :doc:`/components/dependency_injection/index`

* :doc:`/components/dependency_injection/introduction`
Expand Down