Subesh Pokhrel

Magento Developers Blog

Debugging Magento Using Eclipse PDT & Zend Debugger

Latest Post on Debugging Magento: Debugging Magento Using Eclipse on Ubuntu I had always thought of using Eclipse to debug Magento’s complex code flow, and tried number of times before. But without any success I had to abandon it, and thought was not applicable for Magento, remember the fox and the sour grapes :D I also tried using Trial Version of Zend Studio, but with no sucess. But today I was looking at fontis’s blog http://www.fontis.com.au/blog/magento/debugging-with-xdebug and they had indeed used XDebugger and are debugging Magento through command line. So, I thought why not give it a try once again! And as you have already expected i was successfull today!! Wasn’t easy though :P Here’s what I’ve done to get it working on WAMP. Before getting this done I assume you have created a new PHP Project and imported all files, beforehand in Eclipse. Step 1. A very good explanation of downloading Eclipse PDT with Zend Debugger can be found here Installing_the_Zend_Debugger Step 2. Configuring the Zend Debugger can also be found on same location but I would like to emphasize on its setting here, coz I missed myself on first run :D Use these settings for For Zend debugger in php.ini [Zend] zend_extension_ts=D:/wamp/bin/php/php5.2.5/ext/ZendDebugger.dll zend_debugger.allow_hosts=127.0.0.1 zend_debugger.expose_remotely=always You should not forget to enable Zend Debugger extension on WAMP. Now restart Wamp. You are now well set with Eclipse PDT and Zend Debugger. Next thing you need to do is make debugging settings in your Eclipse. Step 3. In you Eclipse Go to Windows–>Preference–>Debug and set as follows debugsettings Step 4. Then Windows–>Preference–>Server and set as follows Debug Server While setting Server configuration you will be prompt to add server path in path mapping, place that relative to your www root Example: /mysite (which will open as localhost/mysite) and select the files in your workspace. Step 5. Now all your settings are done. Now let me tell you about debugging a Block Class of Magento, say Mage_Catalog_Block_Product_List. Go to the class file and add a breakpoint anywhere inside _getProductCollection function. Step 6. Go to Run–>Open Run Dialog and configure as following Run Profile1 Profile 2 Step 7. All set to go now, Run profile as web page Run–>Debug As–>PHP Webpage. You can now see PHP Debug perspective, and use Step Over or Step Into to debug your values. Here is what I got. debugging Hope this might be a life changer.. at least it is for me!