Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a PHP application?

Which is the best way to debug an PHP application as we can debug ASP.NET application with Visual Studio ?

like image 458
Manthan Desai Avatar asked Jul 29 '09 10:07

Manthan Desai


5 Answers

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 !

like image 84
Pascal MARTIN Avatar answered Oct 27 '22 02:10

Pascal MARTIN


PHP Console is good if you want to debug WEB 2.0 (AJAX) web-projects.

like image 43
Teamman Avatar answered Oct 27 '22 02:10

Teamman


PHPEd is great for this, but you have to pay for it.

like image 27
Tom Haigh Avatar answered Oct 27 '22 02:10

Tom Haigh


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.

like image 1
Rich Bradshaw Avatar answered Oct 27 '22 01:10

Rich Bradshaw


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

like image 1
bucabay Avatar answered Oct 27 '22 01:10

bucabay