Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP and WordPress: Debugging

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!

like image 860
Extrakun Avatar asked Jul 03 '09 20:07

Extrakun


People also ask

How do I enable debugging in WordPress?

To enable debugging mode, add the following line to the wp-config. php file: define('WP_DEBUG', true); When this setting is enabled, WordPress displays all PHP errors, notices, and warnings.


2 Answers

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

like image 55
markratledge Avatar answered Sep 20 '22 15:09

markratledge


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.

like image 27
VolkerK Avatar answered Sep 20 '22 15:09

VolkerK