繁体   English   中英

PHP调试:如何配置Xdebug(例如,将其用于Vdebug -Vim插件-)

[英]PHP debugging: How to configure Xdebug (for example, to use it for Vdebug -Vim plugin-)

如何配置Xdebug,使其适用于Vdebug -Vim-PHP调试器?

我正在尝试安装Vdebug以在Vim中调试PHP。 不幸的是,当我按F5键时,此消息几秒钟后出现

Waiting for a connection (Ctrl-C to cancel, this message will self-destruct in
20  seconds...)
No connection was made

我该怎么办?

我解决了,现在Vdebug正常了。

在PHP中启用xdebug编辑您的php.ini文件,并在“模块设置”部分下添加以下内容:

;;;;;;;;;;;;;;;; ; 模块设置; ;;;;;;;;;;;;;;;;

zend_extension = /路径/至/my/xdebug.so

[调试]

; 远端设定

xdebug.remote_autostart =关闭

xdebug.remote_enable =开启

xdebug.remote_handler = dbgp

xdebug.remote_mode = req

xdebug.remote_host =本地主机

xdebug.remote_port = 9000

; 常规xdebug.auto_trace = off

xdebug.collect_includes = on

xdebug.collect_params =关闭

xdebug.collect_return =关闭

xdebug.default_enable =开启

xdebug.extended_info = 1

xdebug.manual_url = http://www.php.net

xdebug.show_local_vars = 0

xdebug.show_mem_delta = 0

xdebug.max_nesting_level = 100

; xdebug.idekey =

; 跟踪选项

xdebug.trace_format = 0

xdebug.trace_output_dir = / tmp

xdebug.trace_options = 0

xdebug.trace_output_name = crc32

; 剖析

xdebug.profiler_append = 0

xdebug.profiler_enable = 0

xdebug.profiler_enable_trigger = 0

xdebug.profiler_output_dir = / tmp

xdebug.profiler_output_name = crc32

试试看

现在一切都准备就绪。 重新启动apache并运行phpinfo()以查看是否出现任何xdebug信息。 如果不是,那么apache error_log + google是您的朋友。

否则,您准备在vim中运行调试器。

在VIM中打开一个PHP脚本,您可以从本地主机访问它。在Web浏览器中打开该PHP脚本。在URL的末尾添加?XDEBUG_SESSION_START = 1在VIM中,按F5键。 您应该在VIM的底部看到“正在等待端口9000上的新连接10秒钟...”,在接下来的10秒钟内,使用URL末尾的“?XDEBUG_SESSION_START = 1”刷新浏览器页面。 返回VIM,您将在调试器中尽享荣耀。 别忘了:要在VIM中的多个窗口之间切换,请按CTRL-ww。

来源-它适用于Ubuntu,尽管它是指另一个Linux发行版-

希望这可以帮助。

我也遇到了这个问题,因为我为Xdebug使用了不同的端口。

如果不是9000,请在〜/ .vimrc上设置

let g:vdebug_options = {}
let g:vdebug_options["port"] = 9001

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM