xdebug.mode是xdebug 3的核心总闸,必须显式设为debug才能触发断点;旧版remote_参数已废弃,需改用client_host、client_port(默认9003)等新配置,并配合start_with_request控制激活时机。

Xdebug 3.x 不再靠 xdebug.remote_enable 这类参数“手动开关”,而是用统一的 xdebug.mode 控制功能启停。漏配或错配这个值,断点就完全不触发——哪怕扩展加载成功、IDE监听开着、端口也通,照样静默失效。
核心开关:xdebug.mode 是调试的总闸门
Xdebug 3 默认关闭所有功能,xdebug.mode 必须显式设为 debug 才能启用调试器。它不是可选项,是必需项。
-
xdebug.mode = debug:仅启用断点、步进等基础调试能力 -
xdebug.mode = debug,develop:加开发增强(美化错误堆栈、显示超全局变量) -
xdebug.mode = debug,profile:同时开启性能分析,生成 cachegrind 文件 -
xdebug.mode = off:彻底禁用 Xdebug(比注释配置更干净)
旧参数全部废弃:remote_* 系列必须删干净
所有带 remote_ 前缀的配置在 Xdebug 3 中已移除,PHP 启动时不会报错,但也不会读取——相当于写了白写,还可能干扰判断。
-
xdebug.remote_enable→ 由xdebug.mode=debug替代 -
xdebug.remote_host→ 改为xdebug.client_host(如127.0.0.1) -
xdebug.remote_port→ 改为xdebug.client_port(默认9003,非旧版9000) -
xdebug.remote_autostart→ 改为xdebug.start_with_request = yes或trigger -
xdebug.remote_connect_back→ 改为xdebug.discover_client_host = true
触发方式更灵活:start_with_request 控制何时启动
不再依赖 cookie 或固定 URL 参数硬编码,Xdebug 3 用 xdebug.start_with_request 统一管理调试器的激活时机:
-
yes:每个 HTTP 请求都自动启动调试(适合本地快速验证) -
no:完全不自动启动,需调用xdebug_break()或xdebug_start_debugging() -
trigger:仅当请求中含XDEBUG_SESSION_START=xxx(任意非空值)才启动
日志与路径:log 和 output_dir 要配对生效
调试连不上?先开日志定位问题根源;profile 文件不生成?大概率是输出路径不可写或没配 xdebug.mode=profile。
-
xdebug.log = /tmp/xdebug.log:记录连接尝试、失败原因,权限要对(web 用户可写) -
xdebug.output_dir = /tmp:所有 profile、trace、gcstats 输出都走这里,必须存在且可写 -
xdebug.profiler_output_name = cachegrind.out.%t.%p:控制 profile 文件名格式(%t 时间戳,%p 进程ID)











