Which is the best way to debug an PHP application as we can debug ASP.NET application with Visual Studio ?
问题:
回答1:
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 !
回答2:
PHP Console is good if you want to debug WEB 2.0 (AJAX) web-projects.
回答3:
PHPEd is great for this, but you have to pay for it.
回答4:
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.
回答5:
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
回答6:
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.
回答7:
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.
回答8:
PHP storm is a good one from JetBrains.