12

I need help with a working step debugging Xdebug 3 config. I am running Xdebug 3.0.1 on Ubuntu server 20.04 with nginx, installed on an Oracle VirtualBox. My IDE is PhpStorm.

Everything is working fine (SSH tunnelling, SFTP, port forwarding), connection is established but step debugging does not begin.

My current Xdebug 3 config:

zend_extension=xdebug.so
xdebug.mode = debug
xdebug.client_host = 127.0.0.1
xdebug.client_port = 9003
XDEBUG_SESSION=PHPSTORM
xdebug.start_with_request=yes

Anyone configured Xdebug 3 in a working step debugging config and can help me??

phpinfo() Xdebug section captured from browser - it's quite lenghty

xdebug Version 3.0.1

Feature Enabled/Disabled    Docs
Development Aids    ✘ disabled  
Coverage    ✘ disabled  
GC Stats    ✘ disabled  
Profiler    ✘ disabled  
Step Debugger   ✔ enabled   
Tracing ✘ disabled  
Debugger    enabled
IDE Key no value
Directive   Local Value Master Value
xdebug.auto_trace   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.auto_trace" This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.auto_trace"
xdebug.cli_color    0   0
xdebug.client_discovery_header  no value    no value
xdebug.client_host  127.0.0.1   127.0.0.1
xdebug.client_port  9003    9003
xdebug.cloud_id no value    no value
xdebug.collect_assignments  Off Off
xdebug.collect_includes This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_includes"   This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_includes"
xdebug.collect_params   This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_params" This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_params"
xdebug.collect_return   Off Off
xdebug.collect_vars This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_vars"   This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.collect_vars"
xdebug.connect_timeout_ms   200 200
xdebug.coverage_enable  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.coverage_enable"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.coverage_enable"
xdebug.default_enable   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.default_enable" This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.default_enable"
xdebug.discover_client_host Off Off
xdebug.dump.COOKIE  no value    no value
xdebug.dump.ENV no value    no value
xdebug.dump.FILES   no value    no value
xdebug.dump.GET no value    no value
xdebug.dump.POST    no value    no value
xdebug.dump.REQUEST no value    no value
xdebug.dump.SERVER  no value    no value
xdebug.dump.SESSION no value    no value
xdebug.dump_globals On  On
xdebug.dump_once    On  On
xdebug.dump_undefined   Off Off
xdebug.file_link_format no value    no value
xdebug.filename_format  no value    no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting    0   0
xdebug.gc_stats_enable  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_enable"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_enable"
xdebug.gc_stats_output_dir  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_output_dir"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.gc_stats_output_dir"
xdebug.gc_stats_output_name gcstats.%p  gcstats.%p
xdebug.halt_level   0   0
xdebug.idekey   no value    no value
xdebug.log  no value    no value
xdebug.log_level    7   7
xdebug.max_nesting_level    256 256
xdebug.max_stack_frames -1  -1
xdebug.mode debug   debug
xdebug.output_dir   /tmp    /tmp
xdebug.overload_var_dump    This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.overload_var_dump"  This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.overload_var_dump"
xdebug.profiler_append  Off Off
xdebug.profiler_enable  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable"
xdebug.profiler_enable_trigger  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger"
xdebug.profiler_enable_trigger_value    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger_value"  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_enable_trigger_value"
xdebug.profiler_output_dir  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_output_dir"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.profiler_output_dir"
xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
xdebug.remote_autostart This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_autostart"   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_autostart"
xdebug.remote_connect_back  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_connect_back"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_connect_back"
xdebug.remote_enable    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_enable"  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_enable"
xdebug.remote_host  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_host"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_host"
xdebug.remote_log   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log" This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log"
xdebug.remote_log_level This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log_level"   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_log_level"
xdebug.remote_mode  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_mode"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_mode"
xdebug.remote_port  This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_port"    This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_port"
xdebug.remote_timeout   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_timeout" This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.remote_timeout"
xdebug.scream   Off Off
xdebug.show_error_trace Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars  Off Off
xdebug.show_mem_delta   This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.show_mem_delta" This setting has been removed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#removed-"xdebug.show_mem_delta"
xdebug.start_upon_error default default
xdebug.start_with_request   1   1
xdebug.trace_enable_trigger This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger"   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger"
xdebug.trace_enable_trigger_value   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger_value" This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_enable_trigger_value"
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_output_dir"   This setting has been changed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-"xdebug.trace_output_dir"
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.trigger_value    no value    no value
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3

xdebug_info() from browser

Version 3.0.1

Feature Enabled/Disabled    Docs
Development Aids    ✘ disabled  
Coverage    ✘ disabled  
GC Stats    ✘ disabled  
Profiler    ✘ disabled  
Step Debugger   ✔ enabled   
Tracing ✘ disabled  
Diagnostic Log
Message Docs
⚠️  [Step Debug] Creating socket for '127.0.0.1:9003', poll success, but error: Operation now in progress (29). 
  [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(   
PHP
Build Configuration
Version 7.4.13
Debug Build no
Thread Safety   disabled
Settings
Configuration File (php.ini) Path   /etc/php/7.4/cli
Loaded Configuration File   /etc/php/7.4/fpm/php.ini
Scan this dir for additional .ini files /etc/php/7.4/fpm/conf.d
Additional .ini files parsed    /etc/php/7.4/fpm/conf.d/10-mysqlnd.ini, /etc/php/7.4/fpm/conf.d/10-opcache.ini, /etc/php/7.4/fpm/conf.d/10-pdo.ini, /etc/php/7.4/fpm/conf.d/15-xml.ini, /etc/php/7.4/fpm/conf.d/20-calendar.ini, /etc/php/7.4/fpm/conf.d/20-ctype.ini, /etc/php/7.4/fpm/conf.d/20-curl.ini, /etc/php/7.4/fpm/conf.d/20-dom.ini, /etc/php/7.4/fpm/conf.d/20-exif.ini, /etc/php/7.4/fpm/conf.d/20-ffi.ini, /etc/php/7.4/fpm/conf.d/20-fileinfo.ini, /etc/php/7.4/fpm/conf.d/20-ftp.ini, /etc/php/7.4/fpm/conf.d/20-gd.ini, /etc/php/7.4/fpm/conf.d/20-gettext.ini, /etc/php/7.4/fpm/conf.d/20-iconv.ini, /etc/php/7.4/fpm/conf.d/20-imagick.ini, /etc/php/7.4/fpm/conf.d/20-imap.ini, /etc/php/7.4/fpm/conf.d/20-intl.ini, /etc/php/7.4/fpm/conf.d/20-json.ini, /etc/php/7.4/fpm/conf.d/20-mbstring.ini, /etc/php/7.4/fpm/conf.d/20-mysqli.ini, /etc/php/7.4/fpm/conf.d/20-pdo_mysql.ini, /etc/php/7.4/fpm/conf.d/20-phar.ini, /etc/php/7.4/fpm/conf.d/20-posix.ini, /etc/php/7.4/fpm/conf.d/20-readline.ini, /etc/php/7.4/fpm/conf.d/20-shmop.ini, /etc/php/7.4/fpm/conf.d/20-simplexml.ini, /etc/php/7.4/fpm/conf.d/20-soap.ini, /etc/php/7.4/fpm/conf.d/20-sockets.ini, /etc/php/7.4/fpm/conf.d/20-sysvmsg.ini, /etc/php/7.4/fpm/conf.d/20-sysvsem.ini, /etc/php/7.4/fpm/conf.d/20-sysvshm.ini, /etc/php/7.4/fpm/conf.d/20-tokenizer.ini, /etc/php/7.4/fpm/conf.d/20-xdebug.ini, /etc/php/7.4/fpm/conf.d/20-xmlreader.ini, /etc/php/7.4/fpm/conf.d/20-xmlrpc.ini, /etc/php/7.4/fpm/conf.d/20-xmlwriter.ini, /etc/php/7.4/fpm/conf.d/20-xsl.ini, /etc/php/7.4/fpm/conf.d/20-zip.ini
George Tiganila
  • 519
  • 1
  • 5
  • 18
  • 1
    1) `XDEBUG_SESSION=PHPSTORM` is a wrong stuff to put in php.ini. 2) What's your PhpStorm version exactly? 2) Please post whole Xdebug section of `phpinfo()` output + maybe `xdebug_info()` as well captured in a same way as you are trying to debug (CLI or a web page -- they can use different php.ini). 4) Enable Xdebug log, try to debug and share the log file -- it will tell where it tries to connect to and what the response is. – LazyOne Jan 07 '21 at 19:58
  • 1
    P.S. What is `127.0.0.2` ? Is it a typo? It has to be an IP of the host OS (where PhpStorm is running). Perhaps you meant to use `127.0.0.1` if SSH tunnelling is involved? Xdebug must be able to connect from inside the VM back to the host OS. – LazyOne Jan 07 '21 at 20:01
  • yes it is a typo, 127.0.0.1 it is. I am using Phpstorm 2020.3.1, Dec 30 Build – George Tiganila Jan 07 '21 at 22:09
  • XDEBUG_SESSION=PHPSTORM was necessary because the IDE is expecting an IDE key, are you saying it will work even without? It is supposed to replace the old xdebug.idekey from version 2 – George Tiganila Jan 07 '21 at 22:11
  • 1
    PhpStorm does not care about IDE key at all. But if you need to specify an IDE key in Xdebug settings -- https://xdebug.org/docs/all_settings#idekey – LazyOne Jan 07 '21 at 22:38
  • 1
    Your xdebug_info() output shows that Xdebug fails to connect. 1) Is PhpStorm is listening for incoming debug requests? Is "phone handle" icon is green/active? 2) Is is actually PhpStorm that listens on that port? Check with `netstat` or whatever you have there on your OS (where IDE is running). 3) What about firewall -- on both host and server. 4) Use `telnet` and try to connect from your server back to IDE (on `127.0.0.1:9003`) -- is it connecting or fails. If fails -- then your SSH tunnel does not work or some firewall. – LazyOne Jan 07 '21 at 22:46
  • 1
    https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html (in case if you have seen it yet); https://www.jetbrains.com/help/phpstorm/troubleshooting-php-debugging.html – LazyOne Jan 07 '21 at 22:47
  • I tried removing IDE key but PHPstorm will throw an error saying it can't be empty. Frankly I can't determine if XDEBUG_SESSION=PHPSTORM is the correct syntax for this.... – George Tiganila Jan 08 '21 at 12:11
  • I ran netstat -a -n | grep LISTEN on vm (ubuntu server) and I think it is not listening to 9003, am I wrong? tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN – George Tiganila Jan 08 '21 at 12:13
  • running netstat on my windows machine I find this: [phpstorm64.exe] TCP 0.0.0.0:9003 mc:0 LISTENING Does this mean I should replace 127.0.0.1 in xdebug config with 0.0.0.0 ? – George Tiganila Jan 08 '21 at 12:18
  • the phone icon in Phpstorm is active – George Tiganila Jan 08 '21 at 12:18
  • firewall allows connections on both host and VM. I do not know how to use telnet to connect, can you point me to the right documentation source for this? – George Tiganila Jan 08 '21 at 12:20
  • 1
    `[phpstorm64.exe] TCP 0.0.0.0:9003` -- this is correct. *"I ran netstat -a -n | grep LISTEN on vm (ubuntu server) and I think it is not listening to 9003, am I wrong?"* You are correct -- I see no SSH tunnel there (based on your output, unless it is shown differently). So double check your SSH tunnelling -- what port is used on the target machine. It can be a different one -- then just use that port in Xdebug setting on PHP end (SSH will forward it back to your local machine on 9003) – LazyOne Jan 08 '21 at 12:21
  • 1
    Telnet? `telnet 127.0.0.1 9003` should work (or if you run without any params, then use `open 127.0.0.1 9003` (may be different on Linux -- this is what I see on my Windows PC) – LazyOne Jan 08 '21 at 12:23
  • Ok, running telnet on the vm I get : telnet: Unable to connect to remote host: Connection refused. This means SSH tunneling fail? – George Tiganila Jan 08 '21 at 12:26
  • 1
    Maybe it's working ... but on a different port. But yes, the message means that there is nothing on local (VM) 9003 port -- either SSH tunnel is not working (or on the different port) .. or nothing is listening right now on the Host (PhpStorm). Double check your SSH Tunnel config first -- https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html – LazyOne Jan 08 '21 at 12:29
  • I am using port 80 and the index.php file stored on the VM is loading in the browser. I am also connected through mobaxterm to the VM ( which is running in headless). I am confused, doesn't all this mean SSH is working fine? – George Tiganila Jan 08 '21 at 12:34
  • Check the link about Reverse SSH Tunnelling and compare to what you are doing. Sounds like you are doing different thing right now. – LazyOne Jan 08 '21 at 12:35
  • THANK YOUUU! I am such a noob. I never created the SSH tunnel... I configured this using what I could find on the internet and no one- literally no one - ever mentioned this....I have been struggling with this issue from before chtistmas.... – George Tiganila Jan 08 '21 at 14:06
  • LIFESAVER @LazyOne! – George Tiganila Jan 08 '21 at 14:07
  • Can you please recommend any other checks/setting so I can make sure nothing will break- even though step debugging works now – George Tiganila Jan 08 '21 at 14:09
  • and if you want to postan answer so I can accept it as solution – George Tiganila Jan 08 '21 at 14:09
  • 1
    Well, you better know how you have fixed it, so please post your own answer with detailed solution (you can accept your own answers) -- this will help others in similar situation (as question with accepted answer is more visible/noticeable). – LazyOne Jan 08 '21 at 14:12
  • oh, allright then – George Tiganila Jan 08 '21 at 14:15

1 Answers1

23

LazyOne helped me, in the comments, to solve it. Apparently, the only issue for my setup was the creation of a SSH tunnel on port 9003 ( for Xdebug3) from here https://www.jetbrains.com/help/phpstorm/remote-debugging-via-ssh-tunnel.html. You can also do it on mobaxterm, not only on puTTY. I have checked and both worked fine.

Also make sure to check firewall sudo ufw status to make sure your VM firewall allows port 9003/tcp connection.

My Xdebug.ini for Xdebug 3 looks like this now:

zend_extension=xdebug.so
xdebug.mode = debug
xdebug.client_host = 127.0.0.1
;# For PhpStorm set below to 9000 (or update IDE's settings).
xdebug.client_port = 9003
xdebug.start_with_request=yes
xdebug.log="/var/log/nginx/xdebug.log"
xdebug.idekey = PHPSTORM
xdebug.discover_client_host=false
Top-Master
  • 7,611
  • 5
  • 39
  • 71
George Tiganila
  • 519
  • 1
  • 5
  • 18
  • 2
    I wrote an article and thought to share as everything is in one place. https://medium.com/@sirajul.anik/install-and-configure-xdebug-3-in-a-docker-container-and-integrate-step-debugging-with-phpstorm-5e135bc3290a – ssi-anik Aug 10 '21 at 02:07
  • 2
    For those using VSCode, the idekey would be `VSCODE`. – Ricardo Metring Nov 02 '21 at 02:15