This guide is intended to get you up and running with XDebug for Visual Studio Code on OS X.
- Visual Studio Code (Insiders) 1.10.0
- OSX El Capitan 10.11.6
- PHP 7.0.15 (installed via homebrew)
- XDebug 2.5.0 (installed via homebrew)
- Homebrew
- Download latest Visual Studio or Visual Studio Insiders
- Install PHP.
homebrew install php7
- Install XDebug
homebrew install xdebug
By default when XDebug is installed via homebrew, the extension will be automatically added/loaded as its configuration file /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini
is additionally parsed; at least on my setup. If not, proceed below.
- Locate configuration file for XDebug or locate
php.ini
. - Either of the two above, make sure you configure the following below:
[xdebug]
zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9090;
Mine happens to use port 9090
as the default 9000
is in use by I don't know which program. To check whether the port is available, use the following command below in the terminal.
Command: netstat -an | grep <port>
.
E.g. netstat -an | grep 9000
Lastly, make sure to restart webserver. Enjoy!
- Debug adapter process has terminated unexpectedly. - First make sure that the port is available. A similar error
EARINUSE
is the same cause for this. Tweak yourlaunch.json
to match your XDebug port configuration. Mine uses9090
to my I configured mylaunch.json
debug settings file to use9090
. - PHP Not Found - This goes that you need to tell VS Code where your php is installed. Use
which php
command in your terminal to get the path and go toVS Code
>Preferences
>Settings
. Add the following line below in your user configuration file. Mine happens to be located at/usr/local/bin/php"
so there you have it below:
"php.validate.executablePath": "/usr/local/bin/php"