WordPress The Right Way
English en-US
English en-US
  • WordPress The Right Way
  • Getting Started
  • Debugging
    • Error Logging
    • Handling Errors
    • Tools
    • Constants of wp-config.php
  • Data
  • Core
  • Code Style Guide
  • I18n
  • JavaScript
  • Multisite
  • Queries
    • User Queries
    • SQL
    • Taxonomy and Term Queries
    • Comment Queries
    • Post Queries
  • Routing
    • The Main Loop & Template Loading
    • What Are Query Variables and Where Do They Come From?
    • Clashes, Slugs, & Debugging
    • Rewrite Rules
  • Security
    • Secure HTTP
    • Standalone PHP Files
  • Servers And Deployment
    • Migrations
    • WP CLI
  • Templates
  • Testing
    • Testing Theory
      • Test Driven Development
      • Unit Testing
      • Behavior Driven Development
    • Testing Plugins
    • WP_UnitTestCase
  • Widgets
  • Community
  • Credits
Powered by GitBook
On this page
  • Debugging Tools / Plugins
  • Xdebug and Remote Debugging
  • PHP Debuggers
  • Browser Web Inspectors
  • Prevention
  1. Debugging

Tools

PreviousHandling ErrorsNextConstants of wp-config.php

Last updated 4 years ago

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

  • Logs usage of deprecated functions.

  • Provides an interface for debugging PHP Notices/Warnings/Errors, reviewing SQL Queries, analysing caching behaviour and much more. It's also extendable with plugins.

  • The Debug Console for example is really useful.

  • View debugging and performance information on database queries, hooks, conditionals, HTTP requests, redirects and more.

Xdebug and Remote Debugging

The PHP Extension allows for enhanced debugging, function and method tracing, and profiling of PHP applications. This is .

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

for Google Chrome

for Mozilla Firefox

for Internet Explorer

for Opera

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

Developer
Log Deprecated Notices
Debug Bar
Debug Console
Query Monitor
Xdebug
installed with VVV and can be turned on/off
PHPStorm
Zend Debugger
zero-configuration debugging
DBG
Chrome DevTools
Firebug
F12 developer tools
Opera Dragonfly
PHP Mess Detector
SCheck
phantm