Which is the best way to debug an PHP application as we can debug ASP.NET application with Visual Studio ?
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.
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 !
You can also have look at these questions that are close to yours :
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
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.