Skip to content
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

Debugging Components: Info for PHP #2526

Closed
wants to merge 1 commit into from
Closed

Conversation

Uplink03
Copy link

Q A
Bug fix? yes/no
New feature? yes/no
Issues Fix #...
License MIT

@carsonbot carsonbot added Bug Bug Fix Feature New Feature Status: Needs Review Needs to be reviewed labels Jan 25, 2025
@smnandre smnandre removed Bug Bug Fix Feature New Feature labels Jan 25, 2025
To debug your PHP code, you can inject a `private LoggerInterface $logger` in your `__construct`.
Then you can use `$this->logger->debug('Message', ['var' => $var]);` and see the output in `var/log/dev.log`.
`dump` won't display anything anywhere (not even the debug toolbar).
`dd` will display in your browser, but will also deadlock your component - you cannot dismiss it and continue working.
Copy link
Member

Choose a reason for hiding this comment

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

This is the same thing in a webpage. dd means dump and die.

@@ -3715,6 +3715,11 @@ Debugging Components
Need to list or debug some component issues.
The `Twig Component debug command`_ can help you.

To debug your PHP code, you can inject a `private LoggerInterface $logger` in your `__construct`.
Then you can use `$this->logger->debug('Message', ['var' => $var]);` and see the output in `var/log/dev.log`.
`dump` won't display anything anywhere (not even the debug toolbar).
Copy link
Member

Choose a reason for hiding this comment

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

This is not true.

During the first render, dumps are shown either in the template or in the debug toolbar.

On following request they are shown on the profiler, like any AJAX request.

Comment on lines +3718 to +3719
To debug your PHP code, you can inject a `private LoggerInterface $logger` in your `__construct`.
Then you can use `$this->logger->debug('Message', ['var' => $var]);` and see the output in `var/log/dev.log`.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is really needed, as it applies to any component / service in Symfony apps (and you can inject a Logger with a lot of other methods,) .

We could send the user towards the documentation pages on logging, but then it would not be really about debugging.

@Kocal Kocal added docs Improvements or additions to documentation TwigComponent labels Jan 26, 2025
@Uplink03
Copy link
Author

This was meant as a quick mention of deficiencies when debugging the component in the browser. I didn't put much thought into it, and I'm not really sure how I phrase it better. I'll withdraw the PR and come back if I have a better one.

@Uplink03 Uplink03 closed this Jan 26, 2025
@smnandre
Copy link
Member

Thank you for opening the PR and making this effort! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation Status: Needs Review Needs to be reviewed TwigComponent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants