Skip to content

Conversation

@emestee
Copy link

@emestee emestee commented Apr 13, 2025

This enables debugging (using xdebug) in vscode

  • Make sure PHP debugger and devcontainer extensions are installed
  • Install docker on your system
  • In .vscode, copy launch.json-devcontainer-dist to launch.json or use its contents for an existing launch.json file
  • Build the devcontainer and switch the workspace to devcontainer

When you run the debug server launch configuration, a PHP webserver inside the devcontainer will start and you will be able to use the vscode debugger: place breakpoints, use watches, catch exceptions, step over etc.

Note that xdebug server runs on your machine and listens on its port 9003. The xdebug client is a php extension that runs in the devcontainer and will connect back to your host, which is why vscode should have port 9003 listed in forwarded ports and it should be green when the web server is running.

- Make sure PHP debugger and devcontainer extensions are installed
- Install docker on your system
- In .vscode, copy `launch.json-devcontainer-dist` to `launch.json` or
  use its contents for an existing launch.json file
- Build the devcontainer and switch the workspace to devcontainer

When you run the debug server launch configuration, a PHP webserver inside the
devcontainer will start and you will be able to use the vscode debugger: place breakpoints,
use watches, catch exceptions, step over etc.

Note that xdebug server runs on your machine and listens on its port 9003.
The xdebug client is a php extension that runs _in_ the devcontainer and will connect
back to your host, which is why vscode should have port 9003 listed in forwarded ports
and it should be green when the web server is running.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant