šŸ” Home

WordPress Dev Environment: Xdebug

One essential process in development is debugging. One tool which can help this process tremendously is Xdebug which allow us to add breakpoints in codes and see what variables are passing and the contents of the variables when the application running. This allows us to debug the codes if we see mistakes in the variables.

To use Xdebug we need to integrate it with the local server. For Windows, there are binaries which can be installed directly to the PHP extension. For Mac, we need to take a bit more steps.

To install Xdebug make sure that you have installed the CLI make tools (https://developer.apple.com/xcode/). Also, make sure you can run phpize from your XAMPP in the terminal. If you cannot run it then add the following line to .bash_profile file in your home directory ( if you donā€™t have it just create it yourself).

export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH

First, let's open the PHP information that we used as a local server. You can open it from PHPInfo link in XAMPP dashboard. Select all texts in the page (CMD + A) and copy them. We need to do this to get a personalized installation from Xdebug page.

Then openĀ https://xdebug.org/wizard.phpĀ and paste the PHPInfo you copied before in here, then analyze the PHP information.

[caption id="attachment_28" align="alignnone" width="2880"]Xdebug Tailored Installation Instructions Xdebug Tailored Installation Instructions[/caption]

You will get a personalized installation step such as this.

Xdebug Tailored Installation Instructions Steps

Just follow the steps explained in the page and Xdebug will be enabled in your server. To check this open PHPInfo from XAMPP dashboard and search for Xdebug.