PHP Debugging

When writing PHP scripts for a complex website, it can be tricky to debug your code and remove bugs. This is due to the fact that you are running your scripts on a remote server (where your site is hosted). Most PHP programmers resort to using the Echo command or the var_dump() function to send debug info to the browser. Whilst this works, it is cumbersome and involves modifying code on the server. A far better way would be to enable real-time debugging on the server itself, which allows you to step through your code and look at the stack, local vars, etc. Is this possible? Of course it is if you have complete access to the server, but what if you don’t?

There is a solution. In a nutshell you need to run a server on your development PC, configure it for debugging and then use a debugging client to enable code step-through. All sounds a bit complicated and it is in fact a slightly messy task, however I have simplified the process for you and detailed it below.

  1. download Apache, with PHP and MySQL (assuming you use MySQL). I find that the Xampp installation is quite convenient and easy to use, with everything you need to run a server on your PC.
  2. download the debug extension to the PHP installation on Xampp.
  3. download the Eclipse debugger client.
  4. follow this tutorial to show you how to setup/debug your new system.

All you need to do is copy your web project files to the project folder (which you set up in Eclipse) and make sure that the project is housed within the htdocs folder of the Xampp installation. Everything should run fine if you followed the steps. I will write a more comprehensive outline of PHP debugging when I have more time. Feel free to ask me questions if you have difficulties.

Best of luck,
Will

One Response to “PHP Debugging”

  1. Php And Mysql Tutorial Apache Says:

    anybody here know of a good site to find more info on Php And Mysql Tutorial Apache? I’ve got this site bookmarked and im gonna keep checking it out, but i still would like to find a site that covers Php And Mysql Tutorial Apache a little more thoroughly..thanks

Leave a Reply

You must be logged in to post a comment.