wodby / drupal-php

PHP docker container image for Drupal
https://wodby.com/stacks/drupal
MIT License
60 stars 81 forks source link

XDebug doesnt work in Linux with VSCode #40

Closed MatthieuScarset closed 5 years ago

MatthieuScarset commented 7 years ago

Hi guys, I am struggling to use XDebug on Linux with VSCode.

Unfortunalely, it does not work out-of-the-box as explained by @PavelPrischepa in https://github.com/wodby/drupal-php/issues/1#issuecomment-247099621 if you dont use PHPStorm :)

Here's my conf:

[...]
 php:
    image: wodby/drupal-php:7.0-2.0.0
#    image: wodby/drupal-php:5.6-2.0.0
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      PHP_XDEBUG: 1
      PHP_XDEBUG_DEFAULT_ENABLE: 1
      PHP_XDEBUG_REMOTE_AUTOSTART: 1
      PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
      # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254"
    volumes:
      - ./:/var/www/html
[...]

In VSCode, here's my launch.json file:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "log": true,
      "localSourceRoot": "${workspaceRoot}/web",
      "serverSourceRoot": "/var/www/html/web"
    }
  ]
}

I start my session with http://<container_ip>/?XDEBUG_SESSION_START=www-data but I am not receiving XDebug response. My breakpoints do not work.

I have tried to uncomment PHP_XDEBUG_REMOTE_HOST and to use PHP 5.6 unfortunately, without any luck.

Any idea what I am doing wrong ? How I can make it work with VSCode ?

pprishchepa commented 7 years ago

@MatthieuScarset try the following config.

You should use the latest image version wodby/drupal-php:7.0-2.4.3.

xDebug config:

PHP_XDEBUG=1
PHP_XDEBUG_DEFAULT_ENABLE=1
PHP_XDEBUG_REMOTE_HOST=172.17.0.1 # your local docker0 IP
PHP_XDEBUG_REMOTE_CONNECT_BACK=0
MatthieuScarset commented 7 years ago

@PavelPrischepa thank you for your answer however, it is not working neither... :cry: What info would you need from my environment in order to help debug this issue?

pprishchepa commented 7 years ago

Have you seen the manual section "With a static IP/single developer"? Maybe it helps you to understand and solve the issue.

csandanov commented 7 years ago

Also see https://github.com/wodby/docker4wordpress/pull/15#issuecomment-317229012

MatthieuScarset commented 5 years ago

Hi @csandanov and @PavelPrischepa I actually fixed my issue and open a PR here to update the doc. https://github.com/lando/lando/pull/1322

Thanks for your help.