How to do Debugging of PHP?

how we do basic debugging in PHP ?

Can anybody share true horror story on debugging PHP application (or (even better) on PHP framework such Codeigniter and WordPress) ?

Read More

i love to hear real experience in case i have to encounter similar situation on my journey to learn PHP.

Related posts

Leave a Reply

4 comments

  1. XDebug may be used to debug a PHP application. Basically you install this on your server and configure it in PHP.ini. Then on your desktop machine, you can setup Netbeans (and maybe Eclipse, but I have not tried that) to remote debug. When you are in a remote debug session you can do any of the things you typically expect: set breakpoints, step through code, etc.

    One major annoyance when using CodeIgniter with mod_rewrite is that the debugger gets confused by index.php not showing up in the URL. I am not sure if this is a problem on the client side or server, and whether CI “eating” the GET portion of a URL has anything to do with it. In any case, I have worked through it by copying a ‘debug.php’ file to the server and starting debugging with that file – everything seems to work fine after that.

    I any case, I highly recommend you get setup with XDebug at some point. You may not use it everyday, but when you need it you’ll be thankful you did your homework ahead of time.

  2. Easiest option (without installing any IDE) is to use firefox FirePHP addon.

    1. Download and install FirePHP firefox addon
    2. Download FirePHP core library from their website
    3. Extract FirePHP library you downloaded in step 2 and only copy FirePHP.class.php to CodeIgniter /application/libraries/ folder, but give it a name FirePHP.php without the class part
    4. Turn PHP’s output buffering on
    5. Start your Firefox, click the FireBug icon on the bottom lower area, or go to menu and select tools. After you turn on (set them to enable) FireBug and FirePHP, be sure to click on the Net tab next in line to HTML, CSS, Script, DOM and set it also to enable.
    6. See this link for how to use firephp library: http://speedtech.it/2009/05/debugging-a-codeigniter-application-with-firephp/
  3. I checked out a lot of debuggers 2 years ago when I wanted to set up a debugging environment for myself in PHP. I posted a brief post on this, you can go through it http://forums.codewalkers.com/general-chat-93/which-php-ide-to-use-840352.html

    Bottomline was that Nusphere’s phped was the best and its debugbreak() function makes debugging a real bliss. With codeigniter also this works fine, no tweaks required if you have already enabled get variable. The only hiccup with codeigniter+phed is that, you cannot do code navigation like “right click and find declaration” for other files models.

    Off late I have been checking out codelobster they have a codeigniter plugin, but I am not through with it yet.