How to do PHP debugging?

How do we do basic debugging in PHP?

Can someone share a true horror story while debugging a PHP application (or (even better) on a PHP framework such as Codeigniter and Wordpress)?

I like to hear real experiences in case I have to face a similar situation on my journey to learn PHP.

+7
debugging php codeigniter wordpress
source share
4 answers

XDebug can be used to debug a PHP application. Basically you install this on your server and configure it in PHP.ini. Then on your desktop computer you can configure Netbeans (and possibly Eclipse, but I have not tried this) to remotely debug. When you are in a remote debugging session, you can do any of the things you usually expect: set breakpoints, execute code, etc.

One of the main annoyances when using CodeIgniter with mod_rewrite is that the debugger is confused by index.php, which does not appear in the url. I'm not sure if this is a problem on the client or server side, and whether the CI "has" a part of the GET URL. In any case, I worked on this by copying the "debug.php" file to the server and started debugging with this file - after that everything works fine.

In any case, I highly recommend that you set up the XDebug setup at some point. You can not use it every day, but when you need it, you will be grateful that you did your homework ahead of time.

+4
source share

The easiest option (without installing the IDE) is to use the Firefox FirePHP addon.

  • Download and install FireFHP firefox addon
  • Download the core FirePHP library from your website.
  • Extract the FirePHP library that you downloaded in step 2 and copy the FirePHP.class.php file to the CodeIgniter / application / libraries / folder, but give it the name FirePHP.php without part of the class
  • Turn PHP output buffering to
  • Launch your Firefox, click the FireBug icon in the lower lower area, or go to the menu and select tools. After you turn on (set them to turn on) FireBug and FirePHP, remember to click the Net tab in the next line in HTML, CSS, Script, DOM and set it also to turn it on.
  • See this link for using the firephp library: http://speedtech.it/2009/05/debugging-a-codeigniter-application-with-firephp/
+2
source share

There is one problem when using IDE debuggers - this is bad for debugging AJAX applications. In this case, you will need to use some browser extensions. For FireFox, it's FirePHP , and Google Chrome is Php console .

+2
source share

I checked a lot of debuggers 2 years ago when I wanted to set up a debugging environment for myself in PHP. I wrote a short entry about this, you can go through it http://forums.codewalkers.com/general-chat-93/which-php-ide-to-use-840352.html

The bottom was that Nusphere phped was the best, and its debugbreak () function makes debugging truly blissful. With codeigniter this works great, no tweaks requiring if you have already enabled variable retrieval. The only hiccup with codeigniter + phed is that you cannot navigate through the code like โ€œright click and ad searchโ€ for other file models.

Recently, I check codelobster they have a codeigniter plugin, but I have not gone through with it yet.

+1
source share

All Articles