{"id":497,"date":"2012-11-16T12:00:37","date_gmt":"2012-11-16T11:00:37","guid":{"rendered":"https:\/\/wprealm.com\/?p=497"},"modified":"2012-11-16T12:00:37","modified_gmt":"2012-11-16T11:00:37","slug":"debugging-tips-in-the-wordpress-context","status":"publish","type":"post","link":"http:\/\/wprealm.local\/debugging-tips-in-the-wordpress-context\/","title":{"rendered":"Debugging Tips for WordPress"},"content":{"rendered":"

Recently I’ve had several discussions with colleagues asking me for the debugging practices that I use. I try to constantly enhance my workflow, resources and improve the quality of my work by speeding up the process of narrowing down the possible reasons for a bug or a feature limitation. Speaking WordPress-wise, I’ll list a couple of things that I consider important. Some of them are more than obvious, but somehow people misuse them or forget about them at a moment of crisis (so to speak).<\/p>\n

Before you start:\u00a0always do backups<\/strong>. Debug your web application locally, test properly and ensure that everything is on set before deploying to the real server. Best practices teach that a local server -> staging\/dev server -> production server is a good setup to prevent the obvious error of hitting the live website.<\/p>\n

<\/p>\n

Environment<\/h2>\n

\"\"I’ve been using plain text editors (vim included) for a while, but usually only for remote\/small changes. I rely on a IDE for better control over the codebase and the relations. I’m an\u00a0Eclipse<\/a>\u00a0user (naturally evolved after several years in the Java world) but you could also check out NetBeans, Sublime, PhpStorm, Komodo or anything else with more capabilities. Using an IDE helps you to set up an easy connection between the codebase and a version control, debugger, (S)FTP and use a number of function suggestions and PHPDoc comments while developing and browsing the code. Xdebug<\/a>\u00a0or the Zend debugger are also a crucial part. Debugging with echo or\u00a0var_dump<\/em>\u00a0(or\u00a0console.log<\/em>\/alert<\/em>) is a quickie for one-liners, but a serious workflow iteration processing requires a debugger.<\/p>\n

I have an article about setting\u00a0Eclipse with Xdebug for Linux<\/a>. I’m also using\u00a0Chrome<\/a>. Safari or Firefox will do the trick too, and for some bugs you need to run several browsers and check if there is a browser-specific bug. For some browser-app attempts such as IE you could nail a large variety of specifics due to their boxing model or JavaScript unique interpretation specifics.<\/p>\n

WordPress setup<\/h2>\n

I’ve been using a number of separate plugins, most of which are already listed on the\u00a0Developer<\/a>\u00a0plugin by\u00a0Automattic<\/a>, along with other best practices. It reminds you about setting\u00a0WP_DEBUG<\/strong>\u00a0and other constants in your wp-config file, as well as install environment testing plugins. In addition to the plugins listed over there, I you may also find the following useful:<\/p>\n