Profiling面板正常显示需同时满足四项条件:一是config/web.php中注册'profiling'=>yii\debug\panels\ProfilingPanel::class;二是Xdebug正确加载且xdebug.mode包含profile(3+版需profile,develop,2版需xdebug.profiler_enable=1);三是YII_DEBUG=true、allowedIPs包含客户端IP、YII_ENV=dev三者全部成立;四是runtime/debug/下有含profiling数据的debug-*.data文件或Profiling页显示非空时间轴。

确认 Profiling 面板是否已启用
打开 config/web.php,在 modules → debug → panels 配置项中检查是否保留了 'profiling' => yii\debug\panels\ProfilingPanel::class 这一行。若被注释或删除,面板将完全不显示,点击调试工具栏后也看不到 Profiling 标签页。
这一步不能跳过——即使 Xdebug 已安装,【profiling 面板未在 panels 中注册,整个性能分析数据就不会被收集】。
验证 Xdebug 是否正确加载并启用 profile 模式
执行 php -v,确认输出中包含 xdebug(不是 xdebug3 或其他变体名称);再运行 php --ri xdebug,检查 xdebug.mode 字段是否包含 profile。
对于 Xdebug 3+(Yii2.0.40 及以上要求),必须设置 xdebug.mode=profile,develop;仅设 develop 或 debug 不会触发函数级耗时采集。旧版 Xdebug 2 则需确保 xdebug.profiler_enable=1 且 xdebug.profiler_output_dir 指向可写路径。
注意:Xdebug 会显著拖慢响应速度,【线上环境绝对不可开启 xdebug.mode=profile】,否则单次请求可能延长数秒甚至超时。
检查调试模块注册前提是否全部满足
第一步:确认 web/index.php 开头存在 defined('YII_DEBUG') or define('YII_DEBUG', true);
第二步:检查 $_SERVER['REMOTE_ADDR'] 是否在 modules.debug.allowedIPs 列表中,例如 ['127.0.0.1', '::1'];若在内网测试机访问,需手动添加对应 IP。
第三步:确认当前环境为 YII_ENV_DEV —— 在入口文件中必须有 defined('YII_ENV') or define('YII_ENV', 'dev');,若设为 'prod' 或 'test',debug 模块根本不会注册,Profiling 面板自然不会出现。
这三个条件缺一不可,任一失败都会导致调试工具栏底部不显示任何图标,更不用说点击进入 Profiling 面板。
查看 Profiling 数据是否实际生成
方法一:访问任意页面后,打开 runtime/debug/ 目录,找到最新生成的 debug-*.data 文件,用文本编辑器打开,搜索 profiling 字段是否存在非空数组。
方法二:在浏览器中打开调试工具栏 → 点击 Profiling 标签页 → 查看左上角是否显示「No profiling data」。若显示该提示,说明 Xdebug 未生效或面板未启用;若显示时间轴但函数列表为空,则大概率是 xdebug.mode 缺少 profile。
方法三:临时在控制器 action 中插入 Yii::beginProfile('test_block'); sleep(1); Yii::endProfile('test_block');,刷新页面后回到 Profiling 面板,确认该 block 是否出现在耗时列表中——这是最直接的连通性验证。



















