Skip to content

Commit

Permalink
[docs] Add rebooting and vpn shutoff to xdebug troubleshooting [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay authored Dec 10, 2021
1 parent 67d99ed commit f3a5e31
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/users/step-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ NOTE: If you are using a PHP version below PHP7.2, you will be using Xdebug vers

Debugging Xdebug in any setup can be a little trouble, but here are the steps to take. The steps here assume that you're using PhpStorm, but they can be adapted to any IDE.

* Temporarily disable any firewall if you're having trouble. Xdebug is a network protocol, and the php process inside the web container must be able to establish a TCP connection to the listening IDE (PhpStorm, for example).
* Reboot your computer.
* Temporarily disable any firewall or vpn if you're having trouble. Xdebug is a network protocol, and the php process inside the web container must be able to establish a TCP connection to the listening IDE (PhpStorm, for example).
* Use `ddev xdebug on` to enable xdebug when you want it, and `ddev xdebug off` when you're done with it.
* Set a breakpoint at the first executable line of your index.php.
* Tell your IDE to start listening. (PhpStorm: Click the telephone button, vscode: run the debugger.)
Expand All @@ -143,6 +144,6 @@ Debugging Xdebug in any setup can be a little trouble, but here are the steps to
* `ddev ssh`: Can `telnet host.docker.internal 9000` connect? If it does, you have something else running on port 9000, probably php-fpm. On the host, use `sudo lsof -i :9000 -sTCP:LISTEN` to find out what is there and stop it, or [change the xdebug port and configure PhpStorm to use the new one](#using-xdebug-on-a-port-other-than-the-default) . Don't continue debugging until your telnet command does not connect.
* Now click the listen button on PhpStorm to start it listening for connections.
* `ddev ssh` and try the `telnet host.docker.internal 9000` again. It should connect. If not, maybe PhpStorm is not listening, or not configured to listen on port 9000?
* Check to make sure that Xdebug is enabled. You can use `php -i | grep Xdebug` inside the container, or use any other technique you want that gives the output of `phpinfo()`, including Drupal's admin/reports/status/php. You should see `with Xdebug v2.9.6, Copyright (c) 2002-2020` and `php -i | grep "xdebug.remote_enable"` should give you `xdebug.remote_enable: On`.
* Check to make sure that Xdebug is enabled. You can use `php -i | grep -i xdebug` inside the container, or use any other technique you want that gives the output of `phpinfo()`, including Drupal's admin/reports/status/php. You should see `with Xdebug v3` and `php -i | grep xdebug.mode` should give you `xdebug.mode => debug,develop => debug,develop"`.
* Set a breakpoint in the first relevant line of the index.php of your project and then visit the site in a browser. It should stop at that first line.
* If you are using PhpStorm inside WSL2 (or perhaps other Linux configurations), under `Help→ Edit Custom VM Options`, add an additional line: `-Djava.net.preferIPv4Stack=true` This makes PhpStorm listen for Xdebug using IPV4; the Linux version of PhpStorm seems to default to using only IPV6.

0 comments on commit f3a5e31

Please sign in to comment.