因此,在浏览了几天但没有成功后,试图弄清楚为什么升级到 Xdebug 3 似乎只能部分适用于我的 Dockerized Laravel 项目,我在这里。我密切关注了升级指南和官方文档以及其他最近的 帖子 ,但我仍然完全困惑为什么调试器不会在断点处停止,除非我手动传递配置选项来运行 Artisan 命令(更多关于这个下面一点)。Xdebug 2 一切正常。
以下是(我认为是)配置文件/输出的相关部分。是的,我意识到多次设置相同的配置,这是尝试许多不同位置来设置这些选项的结果。
码头工人-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.docker文件
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;
我的主机(Windows)php.ini (如果相关)
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
启动.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
},
}
]
}
php -i输出的 Xdebug 部分(删除了不推荐使用的选项)
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
附加模块下的加号
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
正如我所提到的,直接在 CLI 上将选项作为标志运行确实尊重我设置的断点——也就是说,猛击 php 容器,然后运行php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dxdebug.client_port=9001 -dxdebug.client_host=127.0.0.1 artisan some:command
调试器就可以了。
为长度和文件转储道歉,但我现在真的迷路了,所以任何指针都将不胜感激!
编辑:看起来我遇到的任何问题都已在Xdebug 3.0.2中修复。感谢LazyOne的帮助!