[OJS 3.1]How to debug your own code while develop a plugin or child-theme?

Hi everyone.

I am working some modifications for a OJS 3.1 journal through the develop of a Child Theme. In some cases I have to send custom data to some templates. I have read the PKP Theming Guide. However I have searched in this forum about "How to debug code, or print messages to console or log file, so you can make sure that your code is doing what you expect. ", but I have found nothing about it. That’s the why I ask about it.

Hi @juancure

You can debug enabling “show_stacktrace” in your config.inc.php.

Regards,
Israel Cefrin
Public Knowledge Project Team

Hi thanks a lot for your response @israel.cefrin.

I would like to know how send the messages from a Class PHP code. I have seen that some parts of the OJS code have the print_r and var_dump as means for debugging purposes. But I dont know where to see that messages? I have configured my php.ini file to set the path to a log file, then I execute OJS from browser but I dont find anything about the debug messages.

Hi @juancure,

The functions print_r and var_dump will print a variable to the output. So if you included them in your theme’s code, they’d print at the top of your page (you might have to look at the source).

If you want to print things to a log file, try using the error_log function like this:

error_log($any_string_or_integer);
error_log(print_r($array_or_object, true));
1 Like

Hi @NateWr

Thanks a lot for your response, that’s, I was looking for.

1 Like