Xdebug Visual Studio Code



  1. Visual Studio Code Tutorial
  2. Xdebug Visual Studio Code Laravel
  3. Xdebug Visual Studio Code
  4. Xdebug Visual Studio Code Launch.json
  5. Xdebug Visual Studio Code Docker

1. Environment

This blog post describes step by step tutorial to debug PHP applications with Visual Studio Code using XDebug extension on localhost.

Listen for xDebug Method. Now, let’s go through the ‘Listen for xDebug method” which takes the browser into account. Open a.php file, for example, here, the xdebuggertest.php file, inside the info folder of the root directory. Add some code and add some breakpoints. Use the F9 shortcut key to add breakpoints. Install the extension: Press F1, type ext install php-debug. This extension is a debug adapter between VS Code and Xdebug by Derick Rethans. Xdebug is a PHP extension (a.so file on Linux and a.dll on Windows) that needs to be installed on your server. The default value is 9000 (For Xdebug 3 it's 9003) and it is usually enough just to leave it as it is. Note: nginx server using FastCGI may block port 9000 by default. Change Xdebug port to 9001 both in php.ini and in Visual Studio settings. Note that restarting nginx will not reload php.ini! Debugging is a core feature of Visual Studio Code. In this tutorial, we will show you how to run and debug a program in VS Code. We’ll take a tour of the Run View, explore some debugging features, and end by setting a breakpoint. Tip: To use the debugging features demonstrated in this video for Node.js, you will need to first install Node.js.

Mine environment has:

Code
  • Wampserver 3.1.0 32 bit x86
  • Apache 2.4.27 – PHP 5.6.31
  • MySQL 5.7.19
  • Visual Studio Code 1.20.1
  • XDebug

2. Configure XDebug

Open the php.ini file (usually located at: c:wampbinapacheapache2.4.27binphp.ini) and add the following lines at the end of file:

Also, comment this line: Bratz rock angelz game download mac.

3. Install and configure XDebug add-on for your favorite web browser

For Chrome, you can download/install it from here.

For Firefox, you can download/install it from here.

Configure the extension to have proper IDE Key: PHPSTORM

4. Configure VS Code

– Install VS code plugins for PHP. For debugging PHP Debug plugin is required.

After installation, configure PHP intellisense on user level:
File > Preferences > Settings
and add the following section under user settings area:

Do not forget to change “php.validate.executablePath” to the proper path which you are using.

5. Debug

Visual Studio Code Tutorial

Visual studio code tutorial

– Run the xdebug listener in your browser from which you run the website:

– Open your PHP project in VS Code and click on 1st step (check the screenshot):

Xdebug Visual Studio Code Laravel

After click on settings button (2nd step) you should get a dropdown to pick a language for debug configuration. Pick PHP.

Xdebug Visual Studio Code

This confiig is saved per project under: your-site-root-folder/.vscode/launch.json.
Click save file and click on the debug button (3rd step).

Xdebug Visual Studio Code Launch.json

After that, your debugger should be ready for incoming connections and you can put a breakpoint so you can debug.

Xdebug Visual Studio Code Docker

After page reload (in your web browser), VS Code should break the execution at the breakpoint which you have previously set. Example: