I am pretty new to plugin authoring and was having a hard time debuging.
I used lots of echo and it is sloppy and ugly.
I am sure there is a better way to do this, maybe an IDE with a debugger that I can run the entire site in including the plugin?
|
I am pretty new to plugin authoring and was having a hard time debuging. I used lots of echo and it is sloppy and ugly. I am sure there is a better way to do this, maybe an IDE with a debugger that I can run the entire site in including the plugin? |
||||
|
Go into wp-config.php and change |
|||||
|
|
If you're getting errors printed, then x-debug is a brilliant PHP extension that adds modern backtraces to PHP. If you're trying to work out what's going on where there are no errors, my favourite approach is to define a function which logs its output to a file. So I do plog($variable) and that appears in the log file which I can then examine. This is especially useful when you're trying to work out what happened before header() is called, or other situations where you can't print to STDOUT. |
||||
|
|
|
Use xdebug + NetBeans IDE. When fully configured - which is easy to do - you can set break points in your plugin and watch variables at the break points. I think it is the best way to debug plugins or any php applications for that matter. |
||||
|
|
|
I debug the old fashioned way,
So then I just do: |
||||
|
|
|
After tinkering with a number of IDE's, I settled into plain old Notepad++ with an ultra-customized Syntax Highlighting color scheme. I have a macro set up such that when I hit Shift-Ctrl-X , the following code gets output where my cursor is:
It's simple, but I can generally hunt down 90% of my bugs with this macro plus WP_DEBUG enabled. |
||||
|
I wrote a little class for make a logfile, is very useful when you are debugging ajax calls. http://github.com/hunk/Magic-Fields/blob/master/tools/debug.php You only needs do something like: Debug::log("This is a debug message"); When that line is executed a the message will be added in the log file and after that you can use the tail command (if you are using some unix's style operative system) tail -f mylogfile.log If you can pass to this function a array or a object as well. note you needs change the line 20 for a path where you want save your log file |
||||
|
|
|
I use Aptane IDE on Linux and UltraEdit on Windows, and this one also has a PHP-parser. Also, I view all hints from xDebug with the constant See also my post on this topic and feel free to comment and give feedback about your development tools. |
||||
|
|
|
I recommend checking out FirePHP. You can send debug info to Firefox's Firebug over HTTP headers, which usually makes for cleaner debug output. |
||||
|
|
Krumo - the styled php debug classAnother really nice thing is the "krumo" php class. It's implemented in ½ min and offers an easy way to debug all sort of variables:
Plus it helps with backtracing, shows loaded classes or included files and everything on demand. Plus it's FREE!
Screenshot shows the javascript driven folding DownloadKrumo @sourceforge |
||||
|
|
|
There are two IDEs I can recommend and I've used both extensively: PhpED (Windows only) and PhpStorm+XDEBUG (Mac, Windows and Linux.) I'm on Mac now so can only use the latter. Both of them ROCK! The good news that PhpStorm is $49 before September 2010 and only $99 after that. If I was on Windows and had to choose again, not sure which I would choose. Frankly I can't help but feel that any plugin developer not using one of these two tools is severely handicapped, especially if they are relatively new to developing WordPress plugins. |
||||
|
|
|
I use a $13 plugin called LogPress you can buy on ThemeForest and it is an absolute God-send. You can debug everything relating to their plugins and site. Supports Firebug console logging and a whole lot more. I can't live without it, that is how much I use this plugin. This plugin is probably the best money I have ever spent and it has saved countless hours in my Wordpress plugin development. |
||||
|
|
I'm using phpED and xdebug but for me (and seems for somebody else) it's impossible to debug the plugins or theme's file! The debugger only stops on the breakpoints that are in the main or original "core" files! anybody can help me? |
||||
|
|
WP_DEBUGto false, as John recommends, then you get a pretty good idea of what's going wrong, if anything, within your scripts. Then you can edit in Dreamweaver, hit Ctrl+S and then F5 in the browser to immediately view the changes. – EAMann♦ Aug 12 '10 at 0:11