Yet Another WordPress Development Environment and Debugging Post

Since a lot of the feedback from our first WP VIP theme review involved details and polish, I figured I’d post some reminders.  

php.ini settings

display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 0
html_errors = On
error_reporting = E_ALL | E_STRICT

By default, this will dump all the errors to stderr; when using PHP-CGI (PHP-FPM/SpawnFCGI) this outputs the errors to /var/log/nginx/error.log unless you specify a different location in php.ini (error_log = /var/log/syslog for example).

Regarding html_errors = On — if you install xdebug (which absolutely you should, either apt-get install php5-xdebug or apt-get install php-pecl and follow the instructions here: this will take var_dump output and automatically format it so that it’s easy to read (coloured, pre-formatted) and will also give you nice, easy to read php errors.

Here are my php.ini and xdebug.ini files.


I also recommend keeping a clean install of the latest version of WordPress (including betas or release candidates), populated with data from the theme unit test for developing a stand-alone plugin or feature.  I have the following in my wp-config.php file:

define( 'WP_DEBUG', true );
define( 'SAVEQUERIES', true );
define( 'DISABLE_WP_CRON', true );

This ensures errors are properly reported, and that you can use DB debugging tools to review queries, and that wp cron only runs when you explicitly want it to (for testing/debugging).

Basically, I’ll write up the feature and make sure it works great with this clean install of WordPress, and then I’ll migrate the code to the site I need to deploy it on and re-test everything.  This ensures that during development, I am only debugging my plugin and not every other piece of code on the site.  Then I know my code works, and when I add it to the site I can test out the interaction with the other code used.

I have also started using the following plugins in this dev environment:

This combination of plugins gives you a Firebug-like toolbar on any page of the site that shows you the queries that ran, any deprecated functions, any instances of “doing it wrong”, and other cool stuff.Also see:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s