8000 [Debug] Create a main guide for Debugging by wouterj · Pull Request #7071 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Debug] Create a main guide for Debugging #7071

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Bootstrap main debugging guide
  • Loading branch information
wouterj committed Oct 7, 2017
commit 5dc304c2eef330004df6f97a80f1a353e3fa01fb
1 change: 1 addition & 0 deletions _build/redirection_map
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
/components/yaml/index /components/yaml
/deployment/tools /deployment
/install/bundles /setup/bundles
/debug/debugging /debug
/form /forms
/testing/simulating_authentication /testing/http_authentication
/validation/group_service_resolver /form/validation_group_service_resolver
94 changes: 88 additions & 6 deletions debug.rst
9E81
Original file line number Diff line number Diff line change
@@ -1,8 +1,90 @@
Debugging
=========
.. index::
single: Debugging

.. toctree::
:maxdepth: 1
:glob:
How to Optimize your Development Environment for Debugging
Copy link
Member

Choose a reason for hiding this comment

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

"Your"?

==========================================================

debug/*
When you work on a Symfony project on your local machine, you should use the
``dev`` environment (``app_dev.php`` front controller). This environment
conf 8000 iguration is optimized for two main purposes.
Copy link
Member

Choose a reason for hiding this comment

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

End this paragraph with a colon?


* Give the developer accurate feedback whenever something goes wrong (provided
by the web debug toolbar, nice exception pages, profiler, ...);
* Be as similar as possible as the production environment to avoid problems
Copy link
Member

Choose a reason for hiding this comment

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

"Be as close as possible to the production [...]"?

when deploying the project.

Disabling the Bootstrap File and Class Caching
----------------------------------------------

To make Symfony run as fast as possible, it creates big PHP files in your cache
containing the aggregation of PHP classes your project needs for every request.
However, this behavior can confuse your IDE or your debugger. This recipe shows
you how you can tweak this caching mechanism to make it friendlier when you
need to debug code that involves Symfony classes.

The ``app_dev.php`` front controller reads as follows by default::

// ...

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();

To make your debugger happier, disable all PHP class caches by removing the
call to ``loadClassCache()`` and by replacing the require statements like
below::

// ...

// $loader = require_once __DIR__.'/../app/bootstrap.php.cache';
$loader = require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
// $kernel->loadClassCache();
$request = Request::createFromGlobals();

.. tip::

If you disable the PHP caches, don't forget to revert after your debugging
Copy link
Member

Choose a reason for hiding this comment

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

[...] revert these changes after [...]

session.

Some IDEs do not like the fact that some classes are stored in different
locations. To avoid problems, you can either tell your IDE to ignore the PHP
cache files, or you can change the extension used by Symfony for these files::

$kernel->loadClassCache('classes', '.php.cache');
Copy link
Contributor

Choose a reason for hiding this comment

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

is loadClassCache() still a thing? I though it was no longer useful with PHP7

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, let's just remove this section.


Useful Debugging Commands
-------------------------

When developing a large application, it can be hard to keep track of all the
different services, routes and translations. Luckily, Symfony has some commands
that can help you visualize and find the information.
Copy link
Member

Choose a reason for hiding this comment

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

End the paragraph with a colon?


``debug:container``
Displays information about the contents of the Symfony container for all public
services. To find only those matching a name, append the name as an argument.
Copy link
Member

Choose a reason for hiding this comment

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

I think the comma can be removed.


``debug:config``
Shows all configured bundles, their class and their alias.
Copy link
Member

Choose a reason for hiding this comment

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

[...] their classes and their aliases.


``debug:event-dispatcher``
Displays information about all the registered listeners in the event dispatcher.

``debug:router``
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should reference here the router:match command too. In my experience it's very useful for newcomers and is very useful to quickly spot routing problems.

Displays information about all configured routes in the application as a
table with the name, method, scheme, host and path for each route.

``debug:translation <locale>``
Shows a table of the translation key, the domain, the translation and the
fallback translation for all known messages, if translations exist for
Copy link
Member

Choose a reason for hiding this comment

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

Remove the comma?

the given locale.

.. tip::

When in doubt how to use a console command, open the help section by
appending the ``--help`` option.
Copy link
Member

Choose a reason for hiding this comment

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

(-h)

92 changes: 0 additions & 92 deletions debug/debugging.rst

This file was deleted.

0