I have a Joomla plugin that fires after registration. I'm having issues with it but don't know how to debug it properly as the plugin happens only on events.
Up to this point I've been using default Joomla logging:
jimport('joomla.log.log');
JLog::addLogger(array('text_file' => 'myfile.log.php'));
JLog::add('The value is: '.$something);
That's fine but not for arrays. How can I dump the contents of an array to a file (or console) to see what is going on? Currently it will just show "Array".
What about this:
JLog::add('The value is: '.print_r($something, true));
Second parameter of print_r() set to true means that it returns a string instead of outputting it
For debugging the best solution is to use an IDE that works with XDebug (like Eclipse with PDT or Jet Brain's PhpStorm), but they aren't always practical if you trying to debug are remotely hosted Joomla! website.
In that case one of the best solutions is J!Dump which will let you show all of you data types and even pop open a debug window for you with a data and process tree.
You can find it in the Development section of the Joomla! Extensions Directory (JED)
J!Dump other methods are discussed in the "How to debug your code" on Joomla!'s Doc's website
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With