docker 的 Xdebug 未连接

Xdebug for docker not connecting

我正在使用这门课程在 Docker 上设置 Xdebug- https://github.com/markshust/docker-magento

站点已启动,运行 正常,但 Xdebug 无法运行。在 Chrome 浏览器上我有这个设置-

这里启用了-

这是我在 PHPStorm 上的设置:

这是 Run/Debug 配置的样子-

这是我所有的 php 信息-

这是为了表明我没有忘记断点-

我错过了什么?

编辑:Xdebug 配置

编辑:以文本形式- x调试

Version => 3.1.2
Support Xdebug on Patreon, GitHub, or as a business: 
https://xdebug.org/support

         Enabled Features (through 'xdebug.mode' setting)             
Feature => Enabled/Disabled
Development Helpers => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled

                        Optional Features                            
Compressed File Support => yes (gzip)
Clock Source => clock_gettime

Directive => Local Value => Master Value
xdebug.auto_trace => (setting renamed in Xdebug 3) => (setting 
renamed in Xdebug 3)
xdebug.cli_color => 0 => 0
xdebug.client_discovery_header => no value => no value
xdebug.client_host => host.docker.internal => 
host.docker.internal
xdebug.client_port => 9003 => 9003
xdebug.cloud_id => no value => no value
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => (setting removed in Xdebug 3) => 
(setting removed in Xdebug 3)
xdebug.collect_params => (setting removed in Xdebug 3) => 
(setting removed in Xdebug 3)
xdebug.collect_return => Off => Off
xdebug.collect_vars => (setting removed in Xdebug 3) => 
(setting removed in Xdebug 3)
xdebug.connect_timeout_ms => 200 => 200
xdebug.coverage_enable => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.default_enable => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
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 => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => PHPSTORM => PHPSTORM
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 => no value => no value
xdebug.output_dir => /tmp => /tmp
xdebug.overload_var_dump => (setting removed in Xdebug 3) => 
(setting removed in Xdebug 3)
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => (setting renamed in Xdebug 3) => 
 (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger => (setting renamed in Xdebug 3) 
=> (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger_value => (setting renamed in 
Xdebug 3) => (setting renamed in Xdebug 3)
xdebug.profiler_output_dir => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.profiler_output_name => cachegrind.out.%p => 
cachegrind.out.%p
xdebug.remote_autostart => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.remote_connect_back => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.remote_enable => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.remote_host => (setting renamed in Xdebug 3) => (setting 
renamed in Xdebug 3)
xdebug.remote_log => (setting renamed in Xdebug 3) => (setting 
renamed in Xdebug 3)
xdebug.remote_log_level => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.remote_mode => (setting renamed in Xdebug 3) => (setting 
renamed in Xdebug 3)
xdebug.remote_port => (setting renamed in Xdebug 3) => (setting 
renamed in Xdebug 3)
xdebug.remote_timeout => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
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 => (setting removed in Xdebug 3) => 
 (setting removed in Xdebug 3)
 xdebug.start_upon_error => default => default
 xdebug.start_with_request => default => default
xdebug.trace_enable_trigger => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value => (setting renamed in Xdebug 
3) => (setting renamed in Xdebug 3)
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => (setting renamed in Xdebug 3) => 
(setting renamed in Xdebug 3)
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.trigger_value => no value => no value
xdebug.use_compression => 1 => 1
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

当我尝试验证时它看起来像什么-

虽然我不能确切地说出问题是什么,但我建议进行以下更改:

  • 确保 运行 菜单有这个菜单项:
  • 删除 Filter debug connection by IDE key 配置。如果您有多个网站需要转到不同的环境,IDE 键会有些用处,但我猜这对您来说不是问题。
  • 启用Break at first line in PHP scripts.

在故障排除中可能有一些额外的想法 section here

由于您在 Linux/Ubuntu,可能 host.docker.internal 主机条目未在您的本地计算机上设置,这意味着 Xdebug 将无法看到 Docker作为要连接的服务器。

这应该可以通过在本地计算机的 /etc/hosts 文件中添加一个条目来解决,该文件包含 Docker 网络 IP 的值。

您可以通过运行获取Docker网络IP:

docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}'

然后,假设该值为 172.17.0.1,您可以像这样将条目添加到 /etc/hosts

172.17.0.1 host.docker.internal

这会将 host.docker.internal 主机名绑定到您的 Docker 守护程序,因此现在 Xdebug 将能够连接到它。