仅在命令行中设置 Xdebug 断点

2024-04-13php开发问题
10

本文介绍了仅在命令行中设置 Xdebug 断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在为 PHP 维护脚本而苦苦挣扎,我正在寻找一种仅在命令行中使用 xdebug 的方法(如 gdb old-school),但我不知道如何设置断点,请执行一步-进入,跳过并继续.Xdebug 已启动并运行,正如 phpinfo(); 所说.

I'm struggling with a PHP maintenance script and I was looking for a way to use xdebug solely in command line (like gdb old-school), but I couldn't figure out how to set a breakpoint, do a step-into, step-over and continue. Xdebug is up and running, as phpinfo(); says.

我找到了很多关于如何使用 Eclipse 和其他工具执行此操作的文档,但没有关于 CLI 的文档.有人可以帮我吗?我的环境是 Centos 6 和 Bash.

I found a lot of documentation regarding how to do this using Eclipse and other tools, but none to CLI. Could anyone help me? My environment is Centos 6 and Bash.

感谢任何帮助.

谢谢!

推荐答案

这其实是可以的.在 Xdebug 源下载中,您会找到一个名为debugclient"的目录.在此目录中,您将找到一个非常 简单的客户端,它接受原始 DBGP 命令,并以 XML 形式提供输出.要编译,请运行:

This is actually possible. In the Xdebug source downloads, you will find a directory called "debugclient". In this directory you will find a very simple client accepting raw DBGP commands, and giving output as XML. To compile, you run:

  • apt-get install libedit-dev(或等效)
  • ./buildconf
  • ./configure --with-libedit
  • 制作

然后您可以使用 ./debugclient 运行二进制文件.

You can then run the binary with ./debugclient.

然后在不同的 shell 上运行以下命令:

On a different shell, you then run the following:

  • 导出 XDEBUG_CONFIG="idekey=dr"
  • php -dxdebug.remote_enable=1 yourscript.php

debugclient 看到此连接,然后您可以发出直接 DBGP 命令.例如,对于断点,您可以设置:

The debugclient sees this connection, and you then can issue direct DBGP commands. For a breakpoint, you can for example set:

breakpoint_set -i 1 -t line -f file:///path/to/yourscript.php -n 42

-i 1 必须是递增的数字,-f 是文件,-n 是行号.设置断点后,您可以运行 run -i 2 前进到该行.对于所有其他命令,我建议您参阅位于 http://xdebug.org/docs- 的 DBGP 文档dbgp.php

the -i 1 is required to be an increasing number, -f is the file and -n the line number. After setting the breakpoint you can then run run -i 2 to advance to that line. For all other commands, I'd refer you to the DBGP documentation at http://xdebug.org/docs-dbgp.php

这篇关于仅在命令行中设置 Xdebug 断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17