Configure XDebug, Xampp and VSCode in Windows

171
xdebug xampp

Xdebug is an extension for PHP to assist with debugging and development. Xdebug makes development easier by allowing the developer to debug his code in a simple and quick way.

In this article, we will install Xdebug on our Windows machine. I will cover all the required topics. We will use setup on Xampp and VSCode.

Let’s get started.

Check PHPINFO()

The first step before installing Xdebug is to get the phpinfo(). Start your Apache Server and check the phpinfo. We will use installation wizard to select the correct .dll file. Copy all the information from top to bottom of output generated by phpinfo() funciton.

After you copying all the text, go to Installation Wizard link and paste on the input box. Submit the form. It will analyze the our output and provide appropriate instruction.

Alternate to the above method, you can simply run the command shown below and copy all the output. Paste the output to the installation wizard link.

php -i

After analyzing our output, it will provide us a .dll file to download. Download the file.

Move .dll file to PHP directory

After you download the .dll file, move this file to the php installation directory inside ext directory. If you are using Xampp, you to the Xampp installation directory. I have installed Xampp on my G drive. Thus, I will paste the downloaded .dll file to the directory: G:\xampp\php\ext

Edit php.ini file

Now, we need to edit our php.ini file. Open this file which is located at the directory G:\xampp\php. You need to add the following code. You can edit according to your directories.

xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9003
xdebug.client_host = localhost
zend_extension="G:\xampp\php\ext\php_xdebug-3.0.3-7.4-vc15-x86_64.dll"

Install Xdebug extension on VSCode

After all the setup above, let’s install an Xdebug extension on our VSCode. In the extension tab, search for “PHP Debug”, and install the extension by Felix Becker.

Create launch.json

Final step is to create a launch.json file in our project. Navigate to the extension tab on the left side. On “Run and Debug” section, choose add config (PHP). This will create a new launch.json file under .vscode directory.

Run Xdebug

Now, all our setup is ready. We need to create breakpoints on our file and run the debuggin by pressing F5. The code will execute and display different variables, stack on the left side box.

Read More Articles

1 COMMENT

  1. of course like your website however you need to test the spelling on quite a few of your posts. Several of them are rife with spelling problems and I find it very bothersome to tell the reality on the other hand I will definitely come back again.

LEAVE A REPLY

Please enter your comment!
Please enter your name here