Debugging
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? echo
? Come on!
Thanks to Derick Rethans, XDebug can do a ton of cool things for you. For example, it overloads var_dump()
and gives you control over how you want deeply nested data structures to be displayed.
We did an old deep dive using NetBeans and XDebug 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.
Install[edit]
Ensure that XDebug extension is installed for your PHP environment.
in the console, you can php -r 'phpinfo();' | grep -i xdebug
Or, better yet, create a file like info.php
# choose a target
myFile = '../../info.php';
# add the phpinfo() function
echo -e "<?php \nphpinfo();\n" > $myFile;
# add the xdeub_info() function
echo -e "\n\nxdebug_info();\n" >> $myFile;