使用断点进行 PHP 调试 - 案例研究、示例..?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3717136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Debugging with Breakpoints - case studies, examples..?
提问by dmp
I'd really like to get deeper into my php scripts and use things like breakpoints, as I'm doing with JS with firebug.
我真的很想更深入地了解我的 php 脚本并使用断点之类的东西,就像我在用 firebug 处理 JS 一样。
I'd like to know more about what techniques people use, and some solid examples of how to debug with breakpoints a php project.
我想更多地了解人们使用哪些技术,以及如何使用断点调试 php 项目的一些可靠示例。
Thing's I'd like to be able to see..
我希望能够看到的东西..
- Properties of objects
- Class hierarchies.. where objects are coming from, file names etc.. (useful in ZF/Magento)
- Variables, types, content..
- headers, post data, get data, session data, cookies..
- Network / filesystem status..
- 对象的属性
- 类层次结构.. 对象来自哪里,文件名等..(在 ZF/Magento 中有用)
- 变量、类型、内容..
- 标头、发布数据、获取数据、会话数据、cookies..
- 网络/文件系统状态..
I know a lot of this can be done with logging and print_r/vardump etc, but its a bit raw.. and I'd like to be able to use a "continue"/"step-over" etc command on code after hitting a breakpoint, like with firebug.
我知道很多这可以通过日志记录和 print_r/vardump 等来完成,但它有点原始......我希望能够在点击后在代码上使用“继续”/“步进”等命令一个断点,就像萤火虫一样。
from php.ini:
来自 php.ini:
zend_extension_ts = c:\wamp\bin\php\php5.2.11\ext\php_xdebug-2.1.0-5.2-vc6.dll;
xdebug.remote_enable=On;
xdebug.remote_host="localhost";
xdebug.remote_port=9000;
xdebug.remote_handler="dbgp";
回答by greg0ire
Use XDebug, it does most of what you require (not network/filesystem), and with it you can debug from eclipse, zend studio, pdt, or even notepad++
使用 XDebug,它可以完成您需要的大部分工作(不是网络/文件系统),并且您可以使用它从 eclipse、zend studio、pdt 甚至记事本++进行调试
I keep debugging again and again when dealing with Magento, and it is super useful in this case, since Magento's function call stack is very deep.
我在处理 Magento 时不断调试,在这种情况下它非常有用,因为 Magento 的函数调用堆栈非常深。
回答by eHussain
PHP is interpreted and server side scripting language. So, there are only few editors that supports the break point in PHP. And if you are doing the server side scripting then there is no way to debug your script using break points.
PHP 是解释性和服务器端脚本语言。所以,在 PHP 中支持断点的编辑器很少。如果您正在编写服务器端脚本,则无法使用断点调试您的脚本。
However if you are planning to have basic scripting & debugging then you can go with http://www.firephp.org/. Also if you use Zend Studio editor then you will have many options on hand for debugging your script. Zend Studio supports the break point, run & debug options.
但是,如果您打算进行基本的脚本编写和调试,那么您可以使用http://www.firephp.org/。此外,如果您使用 Zend Studio 编辑器,那么您将有许多用于调试脚本的选项。Zend Studio 支持断点、运行和调试选项。
I prefer to log the execution of my script in file.
我更喜欢在文件中记录我的脚本的执行。
Thanks
谢谢