MyBB Community Forums

Full Version: Question about usual debugging techniques for MyBB development
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

At the moment I'm working on a complicated plugin. Basically, whenever anything goes wrong in the PHP code I'm completely blind, and this makes it nigh on impossible to solve the problem.

How can I see what is going on in the code? I've tried the recommended <script>console.log... method but this just causes an encoding error. Also FireBug allows some level of debuggability for JavaScript code files, but doesn't cover the highly nested PHP plugin files. I also found the NetBeans 'debug' feature didn't work right and was just useless.

So how do the developers here 'get eyes into the execution of the code', and debug this stuff?

Cheers!
You can play with error_reporting() http://php.net/manual/it/function.error-reporting.php

If I want to see what's inside an object/array/string/whatsoever I usually print_r() it and exit().
(2015-12-01, 03:36 PM)Shade Wrote: [ -> ]You can play with error_reporting() http://php.net/manual/it/function.error-reporting.php

If I want to see what's inside an object/array/string/whatsoever I usually print_r() it and exit().

I second this.
Update: I got a debugging regime going, that works quite well. I posted it over on mybbhacks:

1) Have a local server. For windows, I have EasyPHP DevServer.
2) Make sure it has XDebug installed. I updated my XDebug on my local server to the latest version as follows:
a) On your local server, make a php file which calls phpinfo(), then open that file in browser.
b) copy and paste that output to http://xdebug.org/wizard.php
c) follow that wizard's instructions
3) Get the latest Netbeans IDE, and install the plugin called "PHP".
4) In Tools > Options > PHP > Debugging, unselect 'Stop at First Line'. If you don't, especially when you're trying to debug something as big as MyBB, it will trigger an invisible breakpoint at the first line of every single php file.
5) Create a New Project in NetBeans, CategoryToungueHP > PHP application with Existing Source
6) Place breakpoints as needed.
7) Click Debug > Debug Project (or CTRL+F5)
8) Profit

This will also work when debugging AJAX, but you have to add &XDEBUG_SESSION_START=netbeans-xdebug to the end of the javascript ajax call url.