为Sublime3配置Xdebug(PHP)path_mapping和php.ini

时间:2017-03-16 16:41:23

标签: php sublimetext3 xdebug

我尝试配置Xdebug以使用Sublime Text 3,但我无法在Context,Watch或Stack标签中显示任何内容,例如通过设置断点并单击开始调试(启动浏览器)。浏览器打开index.php文件,其中?XDEBUG_SESSION_START=sublime.xdebug附加到url,但是在到达断点时代码的执行不会停止。

我还尝试将xdebug_break()添加到index.php无效。

根据我的阅读,在path_mapping文件中指定.sublime-project似乎是最有可能的解决方案。 documentation表示:

  

path_mapping

     

要进行远程调试以解析文件位置,需要将路径映射与服务器路径配置为键,将本地路径配置为值。

我在Windows 10上使用IIS,因此应用程序的文件存储在C:\inetpub\wwwroot\中,主页的网址为http://localhost/index.php我假设分别是服务器路径和本地路径,因此.sublime-project文件如下所示:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "xdebug": {
            "url": "http://localhost/index.php",
            "path_mapping" : {"C:\\inetpub\\wwwroot\\" : "http://localhost/index.php"}
        }
    }
}

这是对的吗?如果是,我的php.ini文件配置是否正确?

[ExtensionList]
.
.
.
zend_extension = "C:\Program Files (x86)\PHP\php-5.6.30-nts-Win32-VC11-x86\ext\php_xdebug-2.5.1-5.6-vc11-nts.dll"

[XDEBUG]
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_host=localhost

1 个答案:

答案 0 :(得分:0)

path_mapping php.ini 设置都不正确。

根据@ LazyOne的评论,删除了path_mapping文件中不正确的.sublime-project,现在看起来像这样:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "xdebug": {
            "url": "http://localhost/index.php"
        }
    }
}

然后将xdebug.remote_log="C:\Windows\Temp\Xdebug\remote.log"添加到 php.ini 并检查显示的日志:

I: Remote address found, connecting to ::1:9000.
E: Time-out connecting to client. :-(

搜索此错误会导致@ Axel对此SO question的回答,并在此基础上将 php.ini 中的xdebug.remote_connect_back=1更改为xdebug.remote_connect_back=0

然后

断点开始工作,上下文监视堆栈标签开始显示到达它们的相关数据。

相关问题