如何调试PHP脚本?

我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。

在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?


当前回答

PhpEdit有一个内置调试器,但我通常最终使用echo();和print_r ();老式的方式!!

其他回答

我使用Netbeans和XDebug。 在它的网站上查看如何配置它的文档。 http://php.netbeans.org/

如果您不想弄乱输出,输出缓冲是非常有用的。我在一行代码中做到了这一点,我可以随意注释/取消注释

 ob_start();var_dump(); user_error(ob_get_contents()); ob_get_clean();

我使用了Zend Studio(5.5)和Zend平台。这就提供了适当的调试、断点/跨代码等,尽管是有代价的。

尝试Eclipse PDT来设置具有您提到的调试特性的Eclipse环境。与var_dump的老方法相比,进入代码的能力是一种更好的调试方法,并在各个点打印,以查看流在哪里出错。当所有这些都失败了,虽然,我只有SSH和vim,我仍然var_dump()/die()找到哪里的代码出错。

Komodo IDE works well with xdebug, even for the remore debugging. It needs minimum amount of configuration. All you need is a version of php that Komodo can use locally to step through the code on a breakpoint. If you have the script imported into komodo project, then you can set breakpoints with a mouse-click just how you would set it inside eclipse for debugging a java program. Remote debugging is obviously more tricky to get it to work correctly ( you might have to map the remote url with a php script in your workspace ) than a local debugging setup which is pretty easy to configure if you are on a MAC or a linux desktop.