2020-11-30 12:04

Xdebug not working on Vscode and Drupal 8 (macOS)

Describe the bug After setting up Drupal 8 and ddev, I used the vscode instructions for setting up xdebug but it never breaks on my index.php file.

To Reproduce Steps to reproduce the behavior:

  1. Install Drupal and ddev.
  2. Install vscode
  3. install php-debug extension
  4. use ddev vscode instructions
  5. use ddev's xdebug debugging instructions:

  6. [X] Make sure xdebug has been enabled in ddev; it's disabled by default for performance reasons. Most people use ddev xdebug on to enable it when they want it, and ddev xdebug off when they're done with it, but it can also be enabled in .ddev/config.yaml. I added breakpoints to index.php

  7. [X] Don't assume that some obscure piece of code is being executed and put a breakpoint there. Start by putting a breakpoint at the first executable line in your index.php. Oh-so-many times people think it should be stopping, but their code is not being executed.
  8. [X] ddev ssh into the web container. Can you ping host.docker.internal (and get responses)? If you can't, you might have an over-aggressive firewall. image
  9. [ ] 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 . Don't continue debugging until your telnet command does not connect.

This is a confusing step, at first I thought I was expecting a connection, but reading it again I see that I am not. Here is what I get, image

lsof is not an available command.

Something that was unclear in the instructions, what should pathMappings be set to? After finishing the instructions of setting up drupal8 with ddev, we have a web directory but the template has "/var/www/html": "${workspaceRoot}". I've tried update pathMappings to /var/www/html/web but it still doesn't break.

versions (if multiple versions listed, I tried both) * ddev: v1.15.3 * php: 7.3/7.2 * drupal: 8.9.3 * xdebug: 2.9.6 * vscode: 1.47.3 * php-debug-extension: 1.13.0/1.12.6

Expected behavior I expect the break point to hit in index.php

Version and configuration information (please complete the following information):

  • Host computer OS and Version: Macos Mojave 10.14.6
  • Docker Desktop version if on macOS or Windows: Version (31259)
  • ddev version information: v1.15.3


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39856630 weixin_39856630 5月前

    downloaded netstat and lsof, lsof returned nothing and maybe this will be more helpful to people that know what it means


    点赞 评论 复制链接分享
  • weixin_39603778 weixin_39603778 5月前

    I haven't tried vscode on macOS, but will give it a try.

    点赞 评论 复制链接分享
  • weixin_39603778 weixin_39603778 5月前

    Based on your description, something is listening on port 9000 on the host (not inside the container). The most likely culprit is php-fpm (you can use ps -ef | grep fpm to look for it, and stop it with (perhaps) brew services stop php if it was installed with homebrew.

    lsof is intended to be used on the host, not inside the container. lsof is included in macOS, it's not something you have to install. From docs on the host, sudo lsof -i :9000 -sTCP:LISTEN . Make sure you have vscode not listening when debugging this, and make sure you don't have PHPStorm or some other IDE listening.

    点赞 评论 复制链接分享
  • weixin_39603778 weixin_39603778 5月前

    No response from OP, so closing. happy to continue the conversation here or elsewhere.

    点赞 评论 复制链接分享
  • weixin_39856630 weixin_39856630 5月前

    This may be related to this https://github.com/felixfbecker/vscode-php-debug/issues/418.

    点赞 评论 复制链接分享