Xdebug PHP extension is required to allow PHP Tools to integrate debugging features into Visual Studio.
Choose the Right Xdebug Binaries
Choose the version depending on your PHP version, but always 32bit. It is strongly recommended to use non-thread safe (NTS) version on Windows.
You can also use following tool provided by Xdebug developers: Xdebug Wizard You can copy and paste in your phpinfo output. It gives you the correct version to download.
Copy Xdebug binary to your PHP Extensions Folder
PHP extensions folder is usually located within your PHP runtime, in
Copy downloaded Xdebug binaries into the PHP extensions folder.
Update PHP Configuration
Edit PHP Configuration file. Its name is usually
php.ini, and is located within your PHP runtime folder.
Add following lines at the end of your configuration file. Change the absolute path for xdebug so it corresponds to correct path on your system.
[XDEBUG] zend_extension = "C:\Program Files (x86)\php-5.4.8\ext\php_xdebug-2.2.1-5.4-vc9-nts.dll" xdebug.remote_enable = on xdebug.remote_handler = dbgp xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.remote_mode = req xdebug.idekey="php-vs"
- From PHP 5.3 onwards, you need to use
- Xdebug is incompatible with Zend Optimizer and Zend Studio Debugger extensions. These extensions should be commented out.
- PHP Tools for Visual Studio has configuration check feature that can recommend and apply configuration changes depending your system.
xdebug.remote_port setting has to be the same as in PHP Tools options (in Visual Studio,
Tools | Options | PHP Tools | Advanced). Default value is
9000 and it is usually sufficient to just leave it as it is.
Note: nginx server using FastCGI may block port
9000by default. Change Xdebug port to
php.iniand in Visual Studio settings. Note that restarting nginx will not reload
php.ini! You will need to restart PHP, or your server.
To verify your Xdebug installation, follow these steps:
Create simple PHP file containing following:
<?php phpinfo(); ?>
- Open the corresponding URL in your browser.
- You should see Xdebug section in the output.
If you don't see the section above in your phpinfo output, there may be something wrong with your PHP configuration or you need to restart your web server to let PHP update its configuration. If PHP Tools debugging session was started before configuration change, it is recommended to close it by exitting its systray icon or restarting Visual Studio.