有没有像 ruby 的调试器一样的交互式 php 调试器?
我观看了 使用 Rails 2 在 15 分钟内创建博客,在视频中 9 分钟后,他展示了 ruby 的交互式调试器,它允许您从正在运行的脚本中调用函数/方法。
这远远超出了断点的范围,看起来非常有用。
PHP 有提供类似功能的东西吗?
I watched the Creating a weblog in 15 minutes with Rails 2 and after 9 minutes in the video he shows ruby's interactive debugger, which allows you to call functions/methods from within a running script.
This goes way beyond breakpoints and looks very useful.
Is there something for PHP that gives similar functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
安装xdebug,然后使用提到的调试客户端之一此处。
Install xdebug and then use one of the debug clients mentioned here.
虽然 Milen 的答案是 2009 年左右唯一正确的答案,并且 Xdebug 仍然是一个有用的工具,但使用它需要您重新编译您的PHP 或编辑
php.ini
运行时配置以将其加载为共享对象。 它还意味着使用支持其网络协议的特定客户端应用程序,例如 PhpStorm 等 IDE。另一种选择是
phpdbg
,它是一个交互式调试器,附带 PHP 核心版本 5.6 及更高版本,并且可以调试为符合 PHP 5.4 或更高版本而编写的 PHP 脚本。使用它很简单:
进入调试器后,输入
help
以访问帮助菜单。如果您的系统上还没有
phpdbg
,可能是因为您的 PHP 配置没有使用--enable-phpdbg
选项。 您可以:./configure
时添加--enable-phpdbg
(这也将简单地构建phpdbg
code> 二进制文件),或者phpdbg
源代码并针对您安装的 PHP 进行编译(假设您有可用的 PHP 源代码)。 执行此操作的说明虽然很少,但位于此处。Although Milen's answer is the only correct one circa 2009, and Xdebug is still a useful tool, using it requires you to recompile your PHP or to edit your
php.ini
runtime configuration to load it as a shared object. It also means using a specific client application that supports its network protocol, such as an IDE like PhpStorm.An alternative is
phpdbg
, which is an interactive debugger that ships with PHP core versions 5.6 and later and can debug PHP scripts written to conform to PHP 5.4 or later.Using it is simple:
Once in the debugger, type
help
to access the help menu.If you don't already have
phpdbg
on your system, it may be because your PHP was configured without the--enable-phpdbg
option. You can either:--enable-phpdbg
when you run./configure
(this will simply also build thephpdbg
binary), orphpdbg
source independently and compile it against your installed PHP (assuming you have the PHP source available). Instructions for doing that, while sparse, are here.