Since a lot of the feedback from our first WP VIP theme review involved details and polish, I figured I’d post some reminders.
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: http://xdebug.org/docs/install) 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.
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:
- Debug Bar
- Debug Bar Console
- Debug Bar Extender
- Log Deprecated Notices
- Core Control
- W3 Total Cache — I develop with this off, then turn it on and test, then test again while not logged in — again, just using a clean WP install with the theme unit test and no other plugins
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: