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

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Oct 20, 2016

This topic was missing the main guide. This PR fixes that and also adds a couple more debugging tips.

/fixes #6342

debug.rst Outdated
.. 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.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.
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?

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
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 [...]"?

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
Copy link
Member

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
Copy link
Member

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
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 [...]

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()``::
Copy link
Member

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).
Copy link
Member

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.
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.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.
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.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.
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.

.. 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)

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
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?

@xabbuh
Copy link
Member

xabbuh commented Dec 16, 2016

I just left some minor comments, but overall I absolutely like this PR. Great work as always Wouter. 👍

Status: Reviewed

@xabbuh
Copy link
Member

xabbuh commented Dec 16, 2016

Oh, and we need to update the /configuration/front_controllers_and_kernel.rst and fix the link (see the failing build job).

debug.rst Outdated
``debug:config``
Shows all configured bundles, their class and their alias.

``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.

@wouterj wouterj force-pushed the debug/create_main_guide branch from 5187505 to 4f21f3a Compare March 19, 2017 17:53
@wouterj
Copy link
Member Author

wouterj commented Mar 19, 2017

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::
Copy link
Contributor

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

Copy link
Member Author

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');
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.

@wouterj wouterj force-pushed the debug/create_main_guide branch from 38d364e to 758a9f7 Compare October 7, 2017 16:01
@wouterj
Copy link
Member Author

wouterj commented Oct 7, 2017

Ready to merge imo

@javiereguiluz
Copy link
Member

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!

@wouterj wouterj deleted the debug/create_main_guide branch December 23, 2020 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants