So, after spending several days of browsing unsuccessfully trying to figure out why upgrading to Xdebug 3 seems to only partially work with my Dockerized Laravel project, here I am. I've closely followed the upgrade guide and official documentation, other recent posts here, and am still completely befuddled as to why the debugger won't stop at breakpoints unless I manually pass in config options to run an Artisan command (more on this a bit below). Everything worked without issue with Xdebug 2.
Below are (what I think are) the relevant portions of config files/outputs. Yes, I realize the same configs are set multiple times, which is a result of trying many different locations to set these options.
docker-compose.yml
php:
build:
context: .
dockerfile: php.dockerfile
container_name: php
environment:
XDEBUG_CONFIG: client_host=host.docker.internal client_port=9001 mode=debug start_with_request=yes
XDEBUG_MODE: debug
volumes:
- ./src:/var/www/html:delegated
ports:
- "9000:9000"
networks:
- v2
php.dockerfile
FROM php:8.0-fpm
WORKDIR /var/www/html
RUN docker-php-ext-install pdo pdo_mysql bcmath \
&& pecl install -f xdebug-3.0.1 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> /usr/local/etc/php/conf.d/xdebug.ini;
My host (Windows) php.ini if relevant
zend_extension=C:\xampp\php\ext\php_xdebug-3.0.1-8.0-vs16-x86_64.dll
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9001
xdebug.idekey=VSCODE
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9001,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/src"
},
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
},
}
]
}
The Xdebug section of php -i output (removed deprecated options)
Feature => Enabled/Disabled
Development Aids => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✔ enabled
Tracing => ✘ disabled
Debugger => enabled
IDE Key =>
Directive => Local Value => Master Value
xdebug.cli_color => 0 => 0
xdebug.client_discovery_header => no value => no value
xdebug.client_host => host.docker.internal => localhost
xdebug.client_port => 9001 => 9003
xdebug.cloud_id => no value => no value
xdebug.collect_assignments => Off => Off
xdebug.collect_return => Off => Off
xdebug.connect_timeout_ms => 200 => 200
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_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 => develop => develop
xdebug.output_dir => /tmp => /tmp
xdebug.profiler_append => Off => Off
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.start_upon_error => default => default
xdebug.start_with_request => default => default
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
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
Plus under Additional modules
XDEBUG_MODE => debug
XDEBUG_CONFIG => client_host=host.docker.internal client_port=9001 mode=debug start_with_request=yes
...
$_SERVER['XDEBUG_MODE'] => debug
$_SERVER['XDEBUG_CONFIG'] => client_host=host.docker.internal client_port=9001 mode=debug start_with_request=yes
...
$_ENV['XDEBUG_MODE'] => debug
$_ENV['XDEBUG_CONFIG'] => client_host=host.docker.internal client_port=9001 mode=debug start_with_request=yes
As I mentioned, running the options as flags on the CLI directly does respect the breakpoints I set -- that is, bashing into the php container and then running php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_port=9001 -dxdebug.client_host=127.0.0.1 artisan some:command
works with the debugger just fine.
Apologies for the length and for the file dump, but I'm truly lost at this point so any pointers would be greatly appreciated!
EDIT: Looks like whatever issue I had was fixed in Xdebug 3.0.2. Thanks to LazyOne for the help!