如何调试PHP脚本?

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

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


当前回答

For the really gritty problems that would be too time consuming to use print_r/echo to figure out I use my IDE's (PhpEd) debugging feature. Unlike other IDEs I've used, PhpEd requires pretty much no setup. the only reason I don't use it for any problems I encounter is that it's painfully slow. I'm not sure that slowness is specific to PhpEd or any php debugger. PhpEd is not free but I believe it uses one of the open-source debuggers (like XDebug previously mentioned) anyway. The benefit with PhpEd, again, is that it requires no setup which I have found really pretty tedious in the past.

其他回答

我使用内置调试器的zend studio for eclipse。与使用eclipse pdt和xdebug进行调试相比,它仍然很慢。希望他们能解决这些问题,在最近的版本中,速度有所提高,但仍然需要2-3秒。 zend firefox工具栏让事情变得非常简单(调试下一页、当前页等)。此外,它还提供了一个分析器,可以对代码进行基准测试,并提供饼状图、执行时间等。

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

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.

Nusphere也是一个很好的php调试器 nusphere

您可以使用Firephp作为firebug的附加组件在与javascript相同的环境中调试php。

我还使用前面提到的Xdebug来分析php。