9

I am writing some plugins and themes for WordPress, and I finding it hard to debug because somehow by the time the page has loaded, $_GET, $_POST and $_REQUEST are all empty. Even with error reporting set on, I am not getting error messages either other than a blank page whenever there is a fatal error. Is there anyway to enable a 'debug mode' for WordPress?

Thanks!

Extrakun
  • 19,057
  • 21
  • 82
  • 129

4 Answers4

12

Pear Debug Wordpress plugin: http://wordpress.org/extend/plugins/wp-pear-debug/

Update 4/08/2015: The above plugin hasn't been updated in a few years. You can also use the built-in WordPress PHP debugging functions in wp-config.php , i.e.:

  // Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define('SCRIPT_DEBUG', true);

See https://codex.wordpress.org/Debugging_in_WordPress for the complete docs

markratledge
  • 17,322
  • 12
  • 60
  • 106
  • As of PHP 7.0 (unsure) that throws almost errors as Exception, it seems that Wordpress sometimes just stop rendering without any error messages. (Of course even though above settings are done. ) Setting `set_exception_handler` https://gist.github.com/kaorukobo/795d43c9a594b021c2d09fffd2935b37 helped this problem. – kaorukobo Mar 05 '17 at 03:23
5

There's (more than one/) a way to enable "a 'debug mode'" for php in general. And that's installing a debugger extension like e.g. xdebug.
You need a client that connects to the debugger and retrieves+displays the information.
Netbeans 6.7 has been released and its php module supports xdebug. It has become a nice IDE for PHP development.

VolkerK
  • 95,432
  • 20
  • 163
  • 226
  • Alas, I am using a hosted webhost, and my PHP development style is to upload directly to the webhost for testing. Thanks though and if I ever do develop on my windows machine I would use this – Extrakun Jul 04 '09 at 11:57
4

I know this has long been answered, but if you define('WP_DEBUG',true); in your wp-config.php and are still not seeing errors, then add this code right after the define statement:

if (WP_DEBUG) ini_set('display_errors',1);

xentek
  • 2,555
  • 2
  • 20
  • 12
3

Look at WordPress FirePHP Debugger (spam link removed). It uses FirePHP for debugging wordpress via the web browser.

Main features:

  • Automatic detection of FirePHP server library inside php include path or separated directory
  • Early loading of the debugger (before WordPress engine starts)
  • No modifications to WordPress core or configuration files
  • Automatic enabling of WordPress debug mode
  • Handles all php fatal errors (no more blank pages and logs parsing)
  • Logs WordPress deprecated functions and arguments
  • Safe debugging on live site
  • SQL queries log
  • PHP superglobals and constants
  • System information (WordPress and server environment)
markratledge
  • 17,322
  • 12
  • 60
  • 106
anton
  • 31
  • 1