0

I have a Vagrant setup for working with bespoke PHP projects, based on Ubuntu 20.10 (Groovy Gorilla) which I use as a base to develop PHP projects. I realized that that version of Ubuntu is out of support, so I updated to hirsute (21.04) (since it still has PHP 7.4) I had a working Xdebug config working, but apparently that broke while upgrading.

I have run sudo ufw allow 9000 to try opening the firewall, but apparently that has not had any effect at all.

What am I missing to get the debugger to attach properly?

xdebug.ini for version 2.x (works):

[XDebug]
zend_extension = "/usr/lib/php/20190902/xdebug.so"
xdebug.remote_enable = true
xdebug.remote_port = 9000
xdebug.remote_autostart = on
xdebug.max_nesting_level = 512
xdebug.remote_host = 10.0.2.2

xdebug.ini for version 3:

[XDebug]
zend_extension = "/usr/lib/php/20190902/xdebug.so"
xdebug.idekey=VSCODE
xdebug.mode=debug
xdebug.client_host=10.0.2.2

xdebug.client_port=9000
xdebug.start_with_request=yes
xdebug.start_upon_error=yes

xdebug.max_nesting_level = 512
xdebug.log="/var/log/apache2/xdebug.log"
xdebug.log_level=10

launch.json:

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/var/www/myProject": "${workspaceFolder}/src/",
              },
            "port": 9000,
            "log": true
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}"
        }
    ]
}

xdebug.log

[2714] Log opened at 2022-01-30 23:49:45.800199
[2714] [Step Debug] INFO: Connecting to configured address/port: 10.0.2.2:9003.
[2714] [Step Debug] INFO: Connected to debugging client: 10.0.2.2:9003 (through xdebug.client_host/xdebug.client_port). :-)
[2714] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/myProject/loginHandler.php" language="PHP" xdebug:language_version="7.4.11" protocol_version="1.0" appid="2714" idekey="VSCODE"><engine version="3.0.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>

[2714] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

[2714] [Step Debug] WARN: 2022-01-30 23:51:01.452897: There was a problem sending 179 bytes on socket 19: Broken pipe.
[2714] Log closed at 2022-01-30 23:51:01.453245

xdebug_info()

PHP
Build Configuration
Version     7.4.11
Debug Build     no
Thread Safety   disabled
Settings
Configuration File (php.ini) Path   /etc/php/7.4/cli
Loaded Configuration File   /etc/php/7.4/apache2/php.ini
Scan this dir for additional .ini files     /etc/php/7.4/apache2/conf.d
Additional .ini files parsed    /etc/php/7.4/apache2/conf.d/10-mysqlnd.ini, /etc/php/7.4/apache2/conf.d/10-opcache.ini, /etc/php/7.4/apache2/conf.d/10-pdo.ini, /etc/php/7.4/apache2/conf.d/15-xml.ini, /etc/php/7.4/apache2/conf.d/20-calendar.ini, /etc/php/7.4/apache2/conf.d/20-ctype.ini, /etc/php/7.4/apache2/conf.d/20-curl.ini, /etc/php/7.4/apache2/conf.d/20-dom.ini, /etc/php/7.4/apache2/conf.d/20-exif.ini, /etc/php/7.4/apache2/conf.d/20-ffi.ini, /etc/php/7.4/apache2/conf.d/20-fileinfo.ini, /etc/php/7.4/apache2/conf.d/20-ftp.ini, /etc/php/7.4/apache2/conf.d/20-gd.ini, /etc/php/7.4/apache2/conf.d/20-gettext.ini, /etc/php/7.4/apache2/conf.d/20-iconv.ini, /etc/php/7.4/apache2/conf.d/20-json.ini, /etc/php/7.4/apache2/conf.d/20-mbstring.ini, /etc/php/7.4/apache2/conf.d/20-mysqli.ini, /etc/php/7.4/apache2/conf.d/20-pdo_mysql.ini, /etc/php/7.4/apache2/conf.d/20-phar.ini, /etc/php/7.4/apache2/conf.d/20-posix.ini, /etc/php/7.4/apache2/conf.d/20-readline.ini, /etc/php/7.4/apache2/conf.d/20-shmop.ini, /etc/php/7.4/apache2/conf.d/20-simplexml.ini, /etc/php/7.4/apache2/conf.d/20-sockets.ini, /etc/php/7.4/apache2/conf.d/20-sysvmsg.ini, /etc/php/7.4/apache2/conf.d/20-sysvsem.ini, /etc/php/7.4/apache2/conf.d/20-sysvshm.ini, /etc/php/7.4/apache2/conf.d/20-tokenizer.ini, /etc/php/7.4/apache2/conf.d/20-xdebug.ini, /etc/php/7.4/apache2/conf.d/20-xmlreader.ini, /etc/php/7.4/apache2/conf.d/20-xmlwriter.ini, /etc/php/7.4/apache2/conf.d/20-xsl.ini, /etc/php/7.4/apache2/conf.d/20-zip.ini
Directive   Local Value Master Value    Docs
xdebug.mode debug   debug
xdebug.start_with_request   yes yes
xdebug.start_upon_error yes yes
xdebug.output_dir   /tmp    /tmp
xdebug.trigger_value    no value    no value
xdebug.file_link_format no value    no value
xdebug.filename_format  no value    no value
xdebug.log  /var/log/xdebug/xdebug.log  /var/log/xdebug/xdebug.log
xdebug.log_level    10  10  
xdebug.var_display_max_children 128 128 
xdebug.var_display_max_data 512 512 
xdebug.var_display_max_depth    3   3   
xdebug.max_nesting_level    512 512 
xdebug.cli_color    0   0   
xdebug.force_display_errors Off Off 
xdebug.force_error_reporting    0   0   
xdebug.halt_level   0   0   
xdebug.max_stack_frames -1  -1  
xdebug.show_error_trace Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars  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.profiler_output_name cachegrind.out.%p   cachegrind.out.%p   
xdebug.profiler_append  Off Off 
xdebug.cloud_id no value    no value    
xdebug.client_host  10.0.2.2    10.0.2.2    
xdebug.client_port  9000    9000    
xdebug.discover_client_host Off Off 
xdebug.client_discovery_header  no value    no value    
xdebug.idekey   VSCODE  VSCODE  
xdebug.connect_timeout_ms   200 200 
xdebug.scream   Off Off 
xdebug.gc_stats_output_name gcstats.%p  gcstats.%p  
xdebug.trace_output_name    trace.%c    trace.%c    
xdebug.trace_format 0   0   
xdebug.trace_options    0   0   
xdebug.collect_assignments  Off Off 
xdebug.collect_return   Off Off 
JoSSte
  • 2,953
  • 6
  • 34
  • 54
  • Your Xdebug log shows that it uses `9003` port and not `9000`. It actually connects somewhere, but then nothing. So double check the ports number. `9003` is the new default port that Xdebug uses instead of `9000` (9000 is also a default port used by php-fpm which often was the reason for failures (Xdebug connects but pfp-fpm rightfully tells it to go away). Check where 9003 can be used in your Vagrant/Docker/etc setup. – LazyOne Feb 14 '22 at 12:41
  • 1
    1) What are you trying to debug -- a web page or a CLI script? On Linux it's very common to have different php.ini configs used by PHP in CLI and a webserver. 2) Please post the full output of `xdebug_info()` captured in the same way as you are trying to debug. It will show the current live values. 3) And a new Xdebug log as well please. – LazyOne Feb 14 '22 at 14:03
  • 1
    it appears that it is an issue in Ubuntu/hirsute, took the exact same xdebug.ini from here and tried on ubuntu/impish, and that worked immediately... – JoSSte Feb 14 '22 at 20:38
  • it appears that all my `vagrant destroy´ and rebuilding the base image have solved the issue. the enclused config for xdebug3 works for me on ubuntu hirsute with pphp 7.4 and impish with php 8.0 (and the correct xdebug.so) – JoSSte Feb 14 '22 at 20:48
  • Glad to hear that you have managed to resolve your issue. Seems like "reboot your PC" approach works even with VM images :) – LazyOne Feb 14 '22 at 22:04

0 Answers0