How do I print debug statements?
I have no front-facing pages other than an ACP configuration page. My extension is primarily a number of event listeners that process event data and make POST calls to a REST endpoint to another service. I've been confused on how I can do basic print statements to ensure things like determining that the right functions are being called.
I tried doing a bunch of echo statements from my listener file (
echo 'called notify_post_created()';), but that resulted in actually rendering a page in my browser. I'd rather this output go to some standard output or log file instead, especially because there are multiple functions chained together that I want to make sure are being called and if they all tried to render their own page I'd only see the last one.
How do I safely dump or otherwise examine data structures?
I wanted to see what was contained in the $event structures being passed into my functions in my listener class, so I attempted to echo that data:
I thought doing this would be harmless, but instead it made my browser unresponsive and forced me to kill it and apache. I saw this data being dumped out onto a page (again, I just want to read this output in my terminal or a log file and not rendered as a page) but there was an enormous amount of information that seemed to be continually written and I couldn't even scroll down to the end. It was almost like it was in an infinite loop when dumping this data.
Is there a recommended technique for examining the contents of data structures?
How do I write data to the logs, and what are the best practices for logging?
I know that there's a log table and also an errors_log file, but I'm unaware of how to write to either one. (are there more logs out there?). I definitely need to log errors when my POST calls fail, but I'm uncertain where those logs should be written or how I can find them. Is there some information on best logging practices?
Is there a native way to do POST and other REST calls in phpBB?
My code currently uses the php curl library to perform the POST calls, but I'd rather not require that users install a 3rd party library on their systems that phpBB does not require (because to my knowledge, phpBB does not list this as a requirement). Is there anything native in phpBB that would allow me to make a POST call?