0

I try to make Xdebug work on my machine for over a month now and its driving me crazy. I have the following configuration:

A Vagrant box with Laravel Homestead (PHP 7.3, Xdebug 2.7.0rc1 on Ubuntu 18.04.1)

On my own computer I have the most recent version of PhpStorm. I've checked the settings for over 10 times now, so I can dream them. The settings of the remote CLI Interpreter are

Remote interpreter

I also have some settings in the PHP > Servers dialog

PHP Servers

When I want to be sure that PHP loads the extensions I use the command php -i | grep xdebug with the result

vagrant@vrfy:~$ php -i | grep xdebug
/etc/php/7.3/cli/conf.d/20-xdebug.ini,
xdebug
...
xdebug.idekey => no value => no value
...
xdebug.remote_enable => On => On
...
xdebug.remote_host => 192.168.10.1 => 192.168.10.1
...
xdebug.remote_port => 9000 => 9000

Note: I also tried to use PHPSTORM as the ide key.

As you can see.

  • Xdebug is installed on the VM
  • PhpStorm knows how to reach the VM with xdebug (validation succeeded)

What am I doing wrong?

EDIT: Phpinfo with xdebug phpinfo

xdebug log

[31052] Log opened at 2019-04-05 12:50:48
[31052] I: Checking remote connect back address.
[31052] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[31052] I: Checking header 'REMOTE_ADDR'.
[31052] I: Remote address found, connecting to 192.168.10.1:9000.
[31052] E: Time-out connecting to client (Waited: 200 ms). :-(
[31052] Log closed at 2019-04-05 12:50:48
[31052]
[31052] Log opened at 2019-04-05 12:50:49
[31052] I: Checking remote connect back address.
[31052] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[31052] I: Checking header 'REMOTE_ADDR'.
[31052] I: Remote address found, connecting to 192.168.10.1:9000.
[31052] E: Time-out connecting to client (Waited: 200 ms). :-(
[31052] Log closed at 2019-04-05 12:50:49
[31052]

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
Koen Hollander
  • 1,687
  • 6
  • 27
  • 42
  • 1) IDE version exactly 2) Are you trying to debug CLI script or a web page? 3) Provide xdebug log for such failed debug attempt – LazyOne Apr 05 '19 at 10:13
  • 1) PhpStorm 2019.1 - Build #PS-191.6183.95 2) Web page - I also have the FF plugin for xdebug 3) There is no log that I can see, maybe I look at the wrong location? @LazyOne – Koen Hollander Apr 05 '19 at 11:24
  • PHP Interpreter is used for CLI stuff only. Your web server may use completely different PHP version or config. So please check what config file is used (and the rest of xdebug config) by checking `phpinfo()` output captured via browser. Config files used will be listed at the top. Xdebug settings, down below in dedicated extension area (close to the end). – LazyOne Apr 05 '19 at 11:28
  • You have `/etc/php/7.3/cli/conf.d/20-xdebug.ini,` -- as you can see it has a `/cli/` part there. For your Apache/php-pfm/etc it may have different folder name instead (e.g. `/apache/` etc) – LazyOne Apr 05 '19 at 11:29
  • When I execute `phpinfo();` on a webpage I can also see the same settings as I shared in my first post. @LazyOne – Koen Hollander Apr 05 '19 at 11:37
  • `xdebug.remote_log` -- provide xdebug log then if your settings are OK (would be good to see them anyway -- xdebug part). If it's empty .. then xdebug may not seeing the "debug me" flag. You may also try placing `xdebug_break();` into your code. Also -- try debugging very simple script first (something like summing 2 variables and echoing the resulting variable). – LazyOne Apr 05 '19 at 11:45
  • 1) The script is very easy (I have one variable / string with an echo) 2) When I use `xdebug_break();` it does not do anything 3) I've added the `/tmp/xdebug.log` file to log stuff to. But after attempting to debug, it does not create the file. @LazyOne – Koen Hollander Apr 05 '19 at 11:58
  • I know only these cases where xdebug does not generate a log: 1) access permissions; 2) xdebug does not try to connect (does not see "debug me" param/cookie etc) 3) SELinux is very restrictive and does not allow outgoing connections (Xdebug) for Apache. Otherwise Xdebug will write into the log. try debugging it via CLI interface (maybe login via SSH and execute command manually (pass all needed commends via params). – LazyOne Apr 05 '19 at 12:08
  • 1
    PS 1) NOTE: with `xdebug.remote_connect_back = 1 / ON` value of `xdebug.remote_host` is ignored. 2) Just in case: it's xdebug that connect to IDE and not other way around. A firewall or IDE not listening on correct port may prevent establishing debug connection. But Xdebug log will record connection attempts. .. So my possible suggestion here: try upgrading xdebug to 2.7 final .. or maybe try older version (PHP 7.2 and Xdebug 2.6.x) – LazyOne Apr 05 '19 at 12:11
  • 1) There is a cookie called `XDEBUG_SESSION` with the name `PHPSTORM` 2) I just made the file xdebug.log in /tmp and changed the permissions to 777 3) SELinux is Disabled 4) The firewall on the guest (VM With homestead) is disabled @LazyOne – Koen Hollander Apr 05 '19 at 12:17
  • 5) both IDE and xdebug are using port `9000` – Koen Hollander Apr 05 '19 at 12:25
  • If you SSH and execute this sort of command remotely: `/user/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=192.168.10.1 /path/to/test.php` ... will it generate any xdebug log? If adding xdebug log path via param? Anything at all? I'm running out of ideas. It could be something simple at the end .. but no better ideas right now. – LazyOne Apr 05 '19 at 12:43
  • Other than that: try restarting VM part (nginx/php-fpm). Check some other questions with the same tags: https://stackoverflow.com/questions/tagged/phpstorm+homestead+xdebug . So far, based on the info you have provided, it should be working. But the "xdebug does not create any log" is what bothers me ... as it's very unusual... – LazyOne Apr 05 '19 at 12:52
  • The darn xdebug is finally logging something when I visit the website. Just added it into the question @LazyOne – Koen Hollander Apr 05 '19 at 13:06
  • Xdebug fails to connect. 1) Check Firewall 2) Ensure it's a correct IP address used (must be an IP where PhpStorm is running as seen from that VM) 3) Make sure it's PhpStorm that listens on TCP 9000 port 4) SSH into and try connect to that IP:port via `nc` or `telnet` – LazyOne Apr 05 '19 at 13:17
  • That is strange, there is no firewall active and I use the `remote_connect_back` parameter, so that should not go wrong... @LazyOne – Koen Hollander Apr 05 '19 at 13:39

0 Answers0