Debugging PHP with Visual Studio Code

Debugging is one of the most important thing of our application development. To make quality software, debugging is a vital part of development.In this post, i am going to show how to debug PHP with visual studio code.

About Visual Studio Code:

Visual studio code, developed by microsoft is an open source code editor features integrated debugging for almost all programming language.

Installation of VS Code:

To get started first visit to download visual studio code. Once VS code installed open it and then you need to install PHP debug extension.

Installation of Xdebug PHP Extension in VS Code:

To install PHP Extension just move to the extension in sidebar icons of VS code or you can press CTRL+SHIFT+X to explore extension. After that type PHP debug in search extension and install it.

Php Xdebug Extension

After successfully installed Extension you need to setup user setting. Just  Go to setting or press CTRL+, you will be move to the setting and change executable path as i am showing below.

Executable Path in VS code

Installation of Xdebug:

To configure xdebug in local server you need to go and paste here your phpinfo(). After that you will get instructions what to do next.To get phpinfo, go to the browser and type localhost you will be move to the dasboard and here you can find the phpinfo menu just click it and copy all the content by pressing CTRL+A.


Xdebug extension

Debugging Setup in VS COde:

Next we need to setup debugging mode in vs code. Just open folder containing PHP Code file and choose the debug mode from the left hand side.

Debug option

Set Breakpoint:

To debug, need to add breakpoint in code. To add breakpoint click on the left of the line where you want to add breakpoint as i am showing showing below.

vscode breakpoint

Breakpoint are indicated by red dot. When execution start on browser, it will stop at breakpoint where we can check the state of the code and variables.

Start Debugging:

To start debugging just click on the start debugging option. For the first time it will create configuration file, no need to change for our puposes .If everything is setup correctly then VS code will be in debbuging mode. Run your page and you will get your debugging environment in VS code with Xdebug.

Xdebug Test


Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. If you face any issue with this code let us know. We’d love to help!




I am Hitesh from Jamshedpur (India). I have been working as a Web Application Developer from last 4+ years. I love diverse and attention catching web presence for a variety of users. Also I love to learn new things in Web Development.

Tags: , , , , , ,
error: Content is protected !!
Secured By miniOrange