Debugging WordPress – from simple to xDebug

Katya Leurdo gave a presentation on "Debugging WordPress - from simple to xDebug".

Debugging WordPress – from simple to xDebug


The fourth meetup of the technical series in the Latvian WordPress group discussed the debugging of WordPress projects. Katya Leurdo gave a presentation on “Debugging WordPress – from simple to xDebug”. In other words, in the course of her presentation, she explored the use of various debugging methods, ranging from simple logging to the powerful xDebug debugger. The proceedings are available for download via the links at the bottom of this article.

However, most of the focus was on using xDebug, with a code example to show what it can do.

Debugging WordPress - from simple to xDebug

Firstly, the presentation began with a focus on using WordPress debug mode constants and working with the debug.log file. Also, the presentation mentioned the new features introduced with WordPress 5.1.

The next part of the presentation discussed an excellent semi-professional debugging tool, Query Monitor plug-in. The speaker explained in detail the information obtainable from this plug-in.

The presentation’s main part contained the explanation of the professional debugging tool for PHP – the xDebug package. The ability to work with xDebug is an indispensable skill for the modern WordPress project developer. Well-known international companies that develop products using WordPress require knowledge of xDebug not only from developers but even from technical support staff.

Debugging WordPress – from simple to xDebug: using xDebug

The report briefly explains the important points in the process of setting up xDebug on the local computer. Detailed setup instructions depend on the software configurations used and are available as numerous manuals on the web.

So, the focus is on showing xDebug in action. This is step-by-step code execution, with entering and exiting functions, viewing the call stack, and viewing variables. The speaker showed the possibilities of analysing local, global and superglobal variables, and their modification. The speaker showed the use of the calculator in phpStorm: performing any calculations, getting results of functions and even executing arbitrary pieces of code in the calculator.

The debug window in phpStorm and how to use it is discussed in detail. The speaker explained all breakpoint usage modes, up to the most complex. She showed the purpose and use of the variable, watches, call stack, output and console windows. Live shows step-by-step code execution with entering a function, exiting it, and executing up to the cursor.

Additionally, the presentation considered debugging process using a live example of a WordPress site. The speaker used a calculator, with the execution of a piece of code in it, using breakpoints with a condition, logging and dependent breakpoints. She paid particular attention to work with the observation window (watches), with the addition of any expressions in it and paste expressions from the calculator. It shows how to access any global variable during debugging, and how to change variables.

The speaker also touched on the problems of debugging ajax and cron requests. During the dialogue examples of using xDebug in complex projects were given.

In the end (as in the report), the speaker answered numerous questions.

Download the presentation of the “Debugging WordPress – from simple to xDebug” meetup here. A recording of the meetup is available below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.