xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
768 stars 175 forks source link

Is there a way to open multiple VSCode instance and start debugging on all of them? #906

Closed mmittnacht closed 1 year ago

mmittnacht commented 1 year ago

I have multiple laravel project, each one opened with it's own VSCode instance. Is it possible to start debug session all of them, so for example when the first repository code calls the second I can hit breakpoints in both instance without the need to stop the first debug session, so I can start in the other.

zobo commented 1 year ago

You can achieve this if all your projects (PHP execution) is running in separated environments and tell each php/xdebug config to use a different client_port. That way you can have multiple debuggers listening at the same time on different ports. (for example 9003, 9004...)

Alternately you could use the Xdebug proxy and use different ideKey, but the first solution is much more stable.

If you are using Laravel Sail you can configure this easily by changing the SAIL_XDEBUG_CONFIG env:

SAIL_XDEBUG_CONFIG=client_host=host.docker.internal,client_port=9010

Then in launch.json of that project change the port inside your Listen for Xdebug...

If you are using Docker there is another option - depending on your setup. If you run VSCode inside the container (VSCode Remote Docker) you can bind the debugger to localhost (inside docker) and have php/xdebug connect to localhost:9003.

Best!

zobo commented 1 year ago

Will close this as the best way to solve this is to just use different ports.