0

I've read countless articles, including this which sounded almost exactly like my setup/issue:

Xdebug inside Docker on Mac M1 2021 is not working

I'm getting the error message mentioned in the title, still.

Here is how I spin up the container (which ships with PHPUnit and XDebug):

docker run --rm -it -v $(pwd):/app -v $(pwd)/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini jitesoft/phpunit /bin/ash

Here is the debug.ini I use to overwrite the defaults:

;
; NOTE: We want to echo these contents to this file location
;
;     PATH: /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
;

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so

xdebug.mode=debug
xdebug.idekey=PHPSTORM
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.client_host=host.docker.internal
xdebug.log=/var/log/xdebug.log

Here is the debug config dump:

[1m__   __   _      _                 
[1m\ \ / /  | |    | |                
[1m \ V / __| | ___| |__  _   _  __ _ 
[1m  > < / _` |/ _ \ '_ \| | | |/ _` |
[1m / . \ (_| |  __/ |_) | |_| | (_| |
[1m/_/ \_\__,_|\___|_.__/ \__,_|\__, |
[1m                              __/ |
[1m                             |___/ 

[0mVersion => 3.2.0
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support

          Enabled Features (through 'XDEBUG_MODE' env variable)          
Feature => Enabled/Disabled
Development Helpers => ✘ disabled
Coverage => ✔ enabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled

                            Optional Features                            
Compressed File Support => no
Clock Source => clock_gettime
'xdebug://gateway' pseudo-host support => yes
'xdebug://nameserver' pseudo-host support => no
Systemd Private Temp Directory => not enabled

                              Diagnostic Log                              
No messages

                                   PHP                                   
                           Build Configuration                           
Version (Run Time) => 8.2.1
Version (Compile Time) => 8.2.1
Debug Build => no
Thread Safety => disabled
                                 Settings                                 
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => (none)
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/date_timezone.ini,
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
/usr/local/etc/php/conf.d/memory-limit.ini


Directive => Local Value => Master Value
xdebug.mode (through XDEBUG_MODE) => coverage => debug
xdebug.start_with_request => yes => yes
xdebug.start_upon_error => default => default
xdebug.output_dir => /tmp => /tmp
xdebug.use_compression => 0 => 0
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.log => /var/log/xdebug.log
xdebug.log_level => 7 => 7
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 => 256 => 256
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 => host.docker.internal => host.docker.internal
xdebug.client_port => 9003 => 9003
xdebug.discover_client_host => Off => Off
xdebug.client_discovery_header => HTTP_X_FORWARDED_FOR,REMOTE_ADDR => HTTP_X_FORWARDED_FOR,REMOTE_ADDR
xdebug.idekey => PHPSTORM => PHPSTORM
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

Here is the result on the console when I try and run index.php for debugging:

[docker://jitesoft/phpunit:latest/]:php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host=host.docker.internal -dxdebug.client_host=host.docker.internal /opt/project/index.php

Process finished with exit code 0

Two things jump out at me

  1. The top of the debug configure dump suggests step debugging is still disabled???
  2. The path to the php script I want to execute on the docker side is /app/index.php not /opt/project/index.php

Thoughts?

Aerendir
  • 6,152
  • 9
  • 55
  • 108
Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68
  • As per what I see ... you need to check your `XDEBUG_MODE` ENV variable (might be set in your Dockerfile/docker-compose. 1) *"Enabled Features (through 'XDEBUG_MODE' env variable)"* 2) *"xdebug.mode (through XDEBUG_MODE) => coverage => debug"* – LazyOne Jan 16 '23 at 01:03
  • P.S. Why are you trying to use `9000` port? Xdebug 3 has changed the default from `9000` to `9003` for a reason, so it's better to stick to it. Of course, if it all setup correctly and works then you can use any desired available & accessible port ... but why "downgrade" (in this sense). – LazyOne Jan 16 '23 at 01:05
  • P.P.S. You should also show what Xdebug log has -- where it tries to connect to, what response it may be getting etc. – LazyOne Jan 16 '23 at 01:06
  • Nothing in the log file, go figure, that's why I didn't post :p – Alex.Barylski Jan 16 '23 at 01:49
  • I guess it's empty because it's not a "debug" (where it need to connect to somewhere) and "coverage" mode may work well without using the log. Have not tested it so cannot confirm though (just a though). – LazyOne Jan 16 '23 at 01:57
  • Work on that `XDEBUG_MODE`. If it's not Dockerfile/docker-compose (or whatever other related file might be)... then check PHPUnit config, it can also easily be there (I originally forgot that PHPUnit is used here). – LazyOne Jan 16 '23 at 02:00

0 Answers0