Wednesday, October 1, 2014

Debugging PHP applications with XDebug

Debugging any PHP application with XDebug is easy and can be configured very easily.

Step 1. Download Eclipse for PHP from the Eclipse website.

e.g.
Step 2. Now download Apache Webserver (Xampp is cool)


You can download a Xampp installer package or alternatively can also download a portable zip or a 7zip package.



Simply, install via installer or uncompress the package in your intended path.

Step 3. Now go to the path where Xampp is installed or unpacked. Open the file \xampp\php\php.ini

Reach to the end under the [XDebug] section and uncomment all the lines beneath.


Set xdebug.remote_enable = 1

Step 4. Download and Install Google Chrome or alternatively download portable version of Google Chrome. 

From Chrome's webstore install the Xdebug Helper plugin.


Step 5. Set the workspace for the Eclipse Projects as xampp\htdocs. Create a new project in PHP let's say Test.
So the path now is xampp\htdocs\Test
Create your own php project. I have shown a small program for example.


Step 6. To start Xampp setup via setup_xampp.bat from the Xampp folder. Then open the Xampp control panel and start the Apache and Mysql process.


Step 7. Enable the XDebug plugin by selecting the Debug option from the options as shown below.


Step 8. From the Eclipse IDE, go to Windows - Preferences - PHP - Debug - Installed Debuggers
Select the XDebug option and click Configure.
Select the Accept remote session (JIT) to localhost in the XDebug settings window and we're ready to go.


Step 9. From the Web browser, reload the php webpage you would like to debug.
Eclipse will then switch to the Debug perspective for you to debug.


Thanks for your patience ...

No comments:

Post a Comment