-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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
Conversation
debug.rst
Outdated
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
How to Optimize your Development Environment for Debugging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Your"?
debug.rst
Outdated
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 | ||
configuration is optimized for two main purposes. |
There was a problem hiding this comment.
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?
debug.rst
Outdated
|
||
* 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 |
There was a problem hiding this comment.
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 [...]"?
debug.rst
Outdated
----------------------------- | ||
|
||
Interactive debug tools allow you to walk through the code step by step, | ||
making it easier to indentify which step is causing problems. Symfony works |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
identify
debug.rst
Outdated
with any PHP debug environment, among them: | ||
|
||
* Xdebug_, the most well-known PHP debugger; | ||
* PsySH_, a PHP REPL_ (Read-eval-print loop) debugger. Use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we always enclose links with backticks?
debug.rst
Outdated
|
||
.. tip:: | ||
|
||
If you disable the PHP caches, don't forget to revert after your debugging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] revert these changes after [...]
debug.rst
Outdated
To ease the debugging of a variable in your application, you can use the | ||
:doc:`VarDumper component </components/var_dumper>` to dump the content of a | ||
variable. The component provides an alternative to the PHP :phpfunction:`var_dump()` | ||
function, in the form of ``dump()``:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] provides the dump()
function, an alternative to PHP's var_dump()
function:
debug.rst
Outdated
The dumper is not limited to scalar values. Arrays and objects can also be | ||
visualized using the VarDumper. One of the most important advantages of using | ||
``dump()`` is a nicer and more specialized dump of objects (e.g. Doctrine | ||
internals are filtered out when dumping a proxy entity). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] dumping an entity proxy
debug.rst
Outdated
|
||
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. |
There was a problem hiding this comment.
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.rst
Outdated
|
||
``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. |
There was a problem hiding this comment.
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.rst
Outdated
services. To find only those matching a name, append the name as an argument. | ||
|
||
``debug:config`` | ||
Shows all configured bundles, their class and their alias. |
There was a problem hiding this comment.
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.
.. tip:: | ||
|
||
When in doubt how to use a console command, open the help section by | ||
appending the ``--help`` option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(-h
)
debug.rst
Outdated
|
||
``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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comma?
I just left some minor comments, but overall I absolutely like this PR. Great work as always Wouter. 👍 Status: Reviewed |
Oh, and we need to update the |
debug.rst
Outdated
``debug:config`` | ||
Shows all configured bundles, their class and their alias. | ||
|
||
``debug:router`` |
There was a problem hiding this comment.
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.
5187505
to
4f21f3a
Compare
Ready to merge, thanks for the great review and sorry for the loooooong delay! |
To ease the debugging of a variable in your application, you can use the | ||
:doc:`VarDumper component </components/var_dumper>` to dump the content of a | ||
variable. The component provides the ``dump()`` function, an alternative to | ||
PHP's :phpfunction:`var_dump()` function:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a not on how to install it or a link for it, as IIRC, unless the application is booted and if you forget to add the dump.php
file in your composer.json
, dump()
won't work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section refers to the VarDumper component installation docs. I don't think we have to duplicate the info here.
debug.rst
Outdated
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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Conflicts: debug/debugging.rst
38d364e
to
758a9f7
Compare
Ready to merge imo |
Wouter, I'm afraid I must close this as "won't fix" because we decided to remove the main debugging article (see #8538) and its contents are moved to different articles of the docs. Cheers! |
This topic was missing the main guide. This PR fixes that and also adds a couple more debugging tips.
/fixes #6342