Neil Walker
Neil Walker

Reputation: 6848

PHP xdebug not working for Visual Studio Code

I have followed to the letter instructions for setting up xdebug with Visual Studio Code: https://blogs.msdn.microsoft.com/nicktrog/2016/02/11/configuring-visual-studio-code-for-php-development/

So all config files, files, etc are installed and tested as working outside of PHP.

Currently I am running PHP using the built in server (php -S localhost:8000 -t).

This works fine and I can see output in my browser. Similarly within VS Code I can run my code fine by running Ctrl + Shift + B. It also works inside Eclipse after installing PDT plugin.

Using phpinfo() I can see that xdebug is there and working fine. However, when I 'listen for XDebug' (I have changed launch.json to use port 8000) or press F5 all that happens is my status bar turns orange, the debug pane shows nothing and the debug buttons show pause/stop and I have to click one of these to quit the program, i.e. it does nothing.

What am I doing wrong?

Upvotes: 2

Views: 4283

Answers (2)

tongadall
tongadall

Reputation: 51

Keep in mind that if you running PHP using the built in server, you must configure the php.ini file of the CLI (in my case is sudo nano /etc/php/5.6/cli/php.ini), not of Apache 2.

Upvotes: 1

Milan Markovic
Milan Markovic

Reputation: 1360

You shouldn't change launch.json to use port 8000, unless you've set xdebug.remote_port=8000 in your php.ini file. The port of the php server and xdebug are two different things. I guess that your xdebugremote_port is 9000 since using port 8000 for both things is impossible, so just change launch.json back to 9000.

Upvotes: 0

Related Questions