I’ve previously posted http://subesh.com.np/2010/01/debugging-magento-eclipse-pdt-zend-debugger but currently I think it was just a snub. What I currently do now is far more better approach then the previous one. Here is how you can set up a debugging environment in Ubuntu using Eclipse for debugging Magento.
[Note: I am describing here based on Ubuntu.]
Step 1: Download and Install Eclipse
Download and Install Eclipse. Choose the relevant package to download. Unzip the package and copy to some location. Lets say /home/user/ Please note that the Eclipse IDE requires that a Java Runtime Environment (JRE) be installed on your machine to run. Java SE 5 or greater is recommended.
Step 2: Setting up PHP Project
Next thing you have to do is to setup the project in Eclipse. Open the Eclipse IDE and it will ask for your Workspace. Browse to your workspace (Where your Magento site is running locally) or by default point it to /var/www and click OK. Now click on File–>New –> New PHP Project, and add your folder name on Project Name and click Finish. Eclipse will take few time on building your project, so take a coffee break if you want and be back in few minutes to go through the steps below.
Step 3: Installing X-Debugger
sudo apt-get install php5-xdebug
Step 4: Configure X-Debugger
Type this in your command prompt.
sudo gedit /etc/php5/apache2/conf.d/xdebug.ini
And add this settings on the .ini file
And restart the apache server.
sudo /etc/init.d/apache2 restart
Step 5: Debug Configuration on Eclipse
On menu click Window–>Preference. Find PHP–>Debug Node in the left. When you click Debug you can see screen like this. Select PHP Debugger – XDebug.
To Set Server click PHP Servers and add new server as follows and click Finish.
Step 6: Configuring debug conf for Magento Projects
On menu click Run–> Debug Configurations. Find PHP Web Page and Right click for adding new configuration. Add something similar to like this.
Step 7: Add Break-Point and start debugging
Now almost all the settings are done. Now you can just add a break-point on your code and start debugging your script by clicking the BUG icon on the top bar.
Few tips though before you start.
- Set up an external browser to run your debug configuation. Go to Window–>Preference and type in web browser in the top left search. And you will get a result. Click on Web Browser to select Use External Web Browser. If that is not clickable first click the restore default button and then the external web browser should be clickable.
- You can enable multi-session debug, because you do not want to always click the debug button after each debug end. For that go to preference. Search for debug. Find PHP –> Debug –>Installed Debugger. Click the XDebug and then click configure. You can then Check the Use Multisession checkbox and save.