简体   繁体   中英

How to debug a PHP application?

哪个是调试PHP应用程序的最佳方法,因为我们可以使用Visual Studio调试ASP.NET应用程序?

I'm using the IDE Eclipse PDT , which can use the PHP extension Xdebug to provide debugging functionnalities, kind of the same way as Visual Studio (a bit less powerful, maybe), which gives you the ability to do things like :

  • step by step
  • step in / out of functions / methods
  • see the content of variables
  • have a stack trace showing where you are

That's really nice to debug big programs -- especially ones you didn't write, to understand how they work (or don't ^^ )

It can also use the extension "zend debugger" ; but I've never tried this one.


Even without using a debugger like the one provided by PDT, Xdebug is a nice extension to have on a development server : it gives nice stack traces when there's an error/exception, it allows you to get nice-looking var_dump 's output, ...

It can also be used to get profiling data, which you can visualize with tools like KCacheGrind , WinCacheGrind , or Webgrind .

But note it is hurting performance badly, so it definitly should not be installed on a production server !

如果要调试WEB 2.0(AJAX)Web项目, PHP控制台是很好的。

PHPEd很适合这个,但你必须付钱。

xdebug works, but you have to install it on the server. I haven't used it, but it seems to have a good reputation.

Some IDEs (Aptana/Eclipse + PHP springs to mind) then can interface with xdebug.

XDebug with Eclipse PDT is the best I've seen. Here is a tutorial on setting this up:

http://devzone.zend.com/article/2930-Debugging-PHP-applications-with-xdebug

NetBeans also has debug capabilities. From the website:

You can debug scripts and web pages, either locally or remotely. The NetBeans PHP debugger integration allows you to map server paths to local paths to enable remote debugging.

I use the Zend debugger and after trouble getting it working (it was a remote setup with he server and the development machine both virtual!) - it made a huge difference to my development efficiency. If you are converting from Visual Studio you will find quite a few things different and even difficult. It is worth sticking with it and mastering howewever - I can now set breakpoints in arbitary pages and navigate to them just like the user, stop and examine locals etc and then step through what happens - put simply now I can find bugs whereas without it I was guessing. Also see Developing with PHP and Eclipse (Galileo) which I found helpful.

来自JetBrains的PHP风暴是一个很好的风暴

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM