Tools

Debugging tools fall into two categories:

  • Tools to diagnose issues when they arise and reveal problems

  • Tools that prevent mistakes and errors from ever happening to begin with

The age old adage still applies: prevention is better than cure

Debugging Tools / Plugins

Installing the plugin Developerarrow-up-right from the WordPress repository will give you quick access to a broad range of debugging tools. The following debugging plugins are quite useful:

Xdebug and Remote Debugging

The Xdebugarrow-up-right PHP Extension allows for enhanced debugging, function and method tracing, and profiling of PHP applications. This is installed with VVV and can be turned on/offarrow-up-right.

With PHPStormarrow-up-right, you can install a browser extension to access Xdebug (or Zend Debuggerarrow-up-right) from within the IDE.

Rather than manually adding var_dump statements and reloading the page, you can add a breakpoint anywhere in your PHP code, execution will stop and you can see a stack trace, inspect (and modify) the values of all variables and objects or manually evaluate (test) a PHP expression.

With zero-configuration debuggingarrow-up-right (controlled via cookies and bookmarklets) you don't need to add ?XDEBUG_SESSION_START to your URLs and you can also debug HTTP post requests.

PHP Debuggers

Browser Web Inspectors

Prevention

There are a number of tools dedicated to analysing code and catching semantic mistakes, or pointing out problems in code.

PHP Mess Detectorarrow-up-right for example, will highlight long variable names, npath and cyclomatic complexity, classes that are too large, unused variables, and other problems. SCheckarrow-up-right is a tool provided by Facebook, and performs similar checks, such as finding dead statements and unused classes.

If you can't type hint, you can make use of a tool such as phantmarrow-up-right to infer types and find clashes. Many others exist though, and integrate with your editor/IDE, so look around

Last updated