Debugging: Difference between revisions

No edit summary
No edit summary
 
Line 1: Line 1:
For now, this subject will focus on PHP.
Debugging a PHP application can involve quite a bit of machinery, and effort getting that machinery setup.  But it's worth it because what alternative is there? <code>echo</code>?  Come on!  
Debugging a PHP application can involve quite a bit of machinery, and effort getting that machinery setup.  But it's worth it because what alternative is there? <code>echo</code>?  Come on!  


Thanks to [http://derickrethans.nl/who.html Derick Rethans], XDebug can do a ton of cool things for you.  For example, it overloads <code>[https://secure.php.net/var_dump var_dump()]</code> and gives '''you''' [http://www.xdebug.org/docs/display control over how you want deeply nested data structures to be displayed].
Thanks to [http://derickrethans.nl/who.html Derick Rethans], XDebug can do a ton of cool things for you.  For example, it overloads <code>[https://secure.php.net/var_dump var_dump()]</code> and gives '''you''' [http://www.xdebug.org/docs/display control over how you want deeply nested data structures to be displayed].
We did an old deep dive using NetBeans and XDebug [[CiviCRM/debugging|on a complex CiviCRM mailer embedded as a module in Drupal]]
A more current setup would be [[debugging Semantic MediaWiki in a Docker container using VSCode with PHPDebug]].


== XDebug ==
== XDebug ==
Line 55: Line 53:


== XDebug with VSCode ==
== XDebug with VSCode ==
Be sure to install the [https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug '''PHP Debug''' extension], and ''read the documentation on that page thoroughly''. The extension only connects your IDE with the PHP environment and the XDebug installation.
VSCode only supports debugging JavaScript out of the box (including Node.js and TypeScript). For PHP and other languages from Go to Python, you will need to install a debugger extension in VSCode. XDebug is the debugger for PHP, and you will need the [https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug '''PHP Debug''' extension] to VSCode. ''READ the documentation on that page thoroughly''. The extension integrates your IDE with the PHP environment and the XDebug debugger itself.


== Step Debugging ==
== Step Debugging ==
Covered at https://xdebug.org/docs/step_debug
Covered at https://xdebug.org/docs/step_debug
== Deeper Dive ==
We did an old deep dive using NetBeans and XDebug [[CiviCRM/debugging|on a complex CiviCRM mailer embedded as a module in Drupal]]
A more current setup would be [[Debug Semantic MediaWiki in Docker using VSCode and XDebug]].
[[Category:Debugging]]
[[Category:Development]]