为 Sublime3 配置 Xdebug (PHP) path_mapping 和 php.ini
Configuring Xdebug (PHP) path_mapping and php.ini for Sublime3
我正在尝试将 Xdebug 配置为与 Sublime Text 3 一起使用,但我无法在上下文、监视或堆栈选项卡中显示任何内容,例如通过设置断点并单击 开始调试(启动浏览器)。浏览器打开 index.php 文件,?XDEBUG_SESSION_START=sublime.xdebug
附加到 url,但代码的执行在到达断点时不会停止。
我也试过将 xdebug_break()
添加到 index.php 但没有效果。
根据我的阅读,在 .sublime-project
文件中指定 path_mapping
似乎是最可能的解决方案。 documentation 指出:
path_mapping
For remote debugging to resolve the file locations it is required to configure the path mapping with the server path as key and local path as value.
我在 Windows 10 上使用 IIS,因此应用程序的文件存储在 C:\inetpub\wwwroot\
中,主页的 url 是 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
path_mapping
和php.ini设置都不正确。
根据@LazyOne 的评论,删除了 .sublime-project
文件中不正确的 path_mapping
,现在它看起来像这样:
{
"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
35=]
Breakpoints 然后开始工作,Context、Watch 和 Stack 选项卡开始显示到达他们的相关数据。
我正在尝试将 Xdebug 配置为与 Sublime Text 3 一起使用,但我无法在上下文、监视或堆栈选项卡中显示任何内容,例如通过设置断点并单击 开始调试(启动浏览器)。浏览器打开 index.php 文件,?XDEBUG_SESSION_START=sublime.xdebug
附加到 url,但代码的执行在到达断点时不会停止。
我也试过将 xdebug_break()
添加到 index.php 但没有效果。
根据我的阅读,在 .sublime-project
文件中指定 path_mapping
似乎是最可能的解决方案。 documentation 指出:
path_mapping
For remote debugging to resolve the file locations it is required to configure the path mapping with the server path as key and local path as value.
我在 Windows 10 上使用 IIS,因此应用程序的文件存储在 C:\inetpub\wwwroot\
中,主页的 url 是 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
path_mapping
和php.ini设置都不正确。
根据@LazyOne 的评论,删除了 .sublime-project
文件中不正确的 path_mapping
,现在它看起来像这样:
{
"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
35=]
Breakpoints 然后开始工作,Context、Watch 和 Stack 选项卡开始显示到达他们的相关数据。