You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

XDebug V3在单PHP文件可用但Laravel项目调试失效求助

XDebug V3在Laravel项目中无法触发断点(单文件调试正常)

已查阅《visual studio code PHP debugging not working》《XDebug not working in VScode for php debugging》等Stack Overflow帖子,仍无法让XDebug在Laravel项目中正常工作。使用VSCode和XDebug V3,调试单PHP文件时断点可正常触发,但Laravel项目中的断点毫无反应。

配置信息

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "stopOnEntry": true,
            "log": true,
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000,
            "pathMappings": {
                "C:/xampp/htdocs/myLaravelProject": "${workspaceFolder}"
            }
        }
    ]
}

php.ini

[XDebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = trigger
xdebug.remote_port = 9000
xdebug.client_port = 9000

场景对比

正常工作场景:单文件index.php

<?php 

$i = 1 + 4;

echo $i; // 此处断点正常触发

无法工作场景:Laravel项目/routes/web.php

<?php 

Route::get('/test-breakpoint', function()
{
   $i = 1 + 4;

   echo $i; // 此处断点无法触发
});

内容的提问来源于stack exchange,提问作者Linesofcode

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 10:17:13