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 Developer from the WordPress repository will give you quick access to a broad range of debugging tools. The following debugging plugins are quite useful:

  • Log Deprecated Notices Logs usage of deprecated functions.
  • Debug Bar Provides an interface for debugging PHP Notices/Warnings/Errors, reviewing SQL Queries, analysing caching behaviour and much more. It's also extendable with plugins.
  • Debug Console The Debug Console for example is really useful.
  • Query Monitor View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.

Xdebug and Remote Debugging

The Xdebug 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/off.

With PHPStorm, you can install a browser extension to access Xdebug (or Zend Debugger) 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 debugging (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

  • DBG - PHP Debugger and Profiler

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 Detector for example, will highlight long variable names, npath and cyclomatic complexity, classes that are too large, unused variables, and other problems. SCheck 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 phantm to infer types and find clashes. Many others exist though, and integrate with your editor/IDE, so look around

results matching ""

    No results matching ""