XF 2.0 debug: best practices for displaying variables (console log, file system or xf_admin_log for crons ...)


Well-known member
Is there a best practice for displaying variables when writing an addon?

1. If I write a cron, what is the preferred debug method? Writing to the admin log? Or to a file system, is that possible?

2. For functions like preSave(), is it best to show the output in the browser console log? Is there an xf function to do that?

Or do you recommend xdebug or another external tool ? What do you use for debugging?

Lukas W.

Formerly katsulynx
There are \XF::dump($variable) and \XF::dumpSimple($variable) at your hand. When you run a cron job manually, those two will deliver their output to the result page pf the cron execution. As long as you're not doing ajax stuff, they will also work perfectly fine in places like preSave()-functuions, etc. If ajax comes in, I stick with phps var_dump($variable), that will throw the stuff into the browser console as XF is not able to parse the reply.