Wednesday, June 03, 2009

Debugging Magento: Vista, XAMPP, & Zend Studio for Eclipse

Here are some notes about what worked for me for being able to debug Magneto in Zend Studio for Eclipse using XAMPP on Vista.

For debugging with PDT & xDebug, use this excellent site. My php.ini for xDebug:
[XDebug]
zend_extension_ts = D:\xampp\php\ext\php_xdebug-2.1.0-5.2-vc6.dll
zend_debugger.allow_hosts=127.0.0.1/24, 192.168.20.107/108
xdebug.remote_enable=On
xdebug.remote_host=127.0.0.1/24, 192.168.20.107/108
xdebug.remote_port=8080
xdebug.remote_handler=dbgp

XAMPP
Download the Window's Installer version of XAMPP. I have all 4 programs (MySQL, Apache, FileZilla FTP Server, and Mercury SMTP server) all running as services that boot on startup. Make sure you have at least XAMPP version 1.7.1. Afterwards, follow the EXCELLENT Magento installation instructions by Max Berndt (thanks Max!).

ZEND DEBUGGER
I don't have full notes here, but I do remember that I had a lot of problems, and in the end used the zend debugger from the PDT even though I own a licensed version of Zend Studio for Eclipse. I downloaded org.zend.php.debug.debugger.win32.x86_5.2.15.v20081217.jar from http://downloads.zend.com/pdt/plugins/, and used 7zip to open the jar and extract ZendDebugger.dll from the resource/php5 directory, and copied it into C:\xampp\php\ext\. I then commented out all the lines from the [Zend], [XDebug], and [DEBUGGER] sections of the php.ini file. I then added the following 3 lines to the [DEBUGGER] section before rebooting Apache...
zend_extension_ts=C:\xampp\php\ext\ZendDebugger.dll
zend_debugger.allow_hosts=127.0.0.1/24, 192.168.20.25/39
zend_debugger.expose_remotely=always
I don't remember where I got the exact allow_hosts, but I do know that the default values that I had caused Apache to crash, and the above finally worked for me.
Here you might also want to refer to the article PHP Debug with Zend Debugger And Eclipse PDT Tutorial Part 1.

ZEND STUDIO FOR ECLIPSE
The following assumes that Magento can be reached from http://127.0.0.1/magento
- From the "Run" menu, select "Debug Configurations"
- On the left, right-click on "PHP Web Page" and select "New"
- Name: Magento
- Server Debugger: Zend Debugger
- PHP Server: Click on the "New" link
- Name: Magento Server, URL http://127.0.0.1 (do NOT use localhost - I don't have notes on this, but I'm sure that I had trouble accessing the admin area using local host, and switching to http://127.0.0.1 fixed the problem).
- Hit next, going to the Server Path Mapping, and "Add"
- Path on Server: the windows path to your magento dir, e.g. C:\Users\Ed\workspace\magento
- Path in Workspace: /magento
- Click Finish
- Now back in the "Debug Configurations" dialog, set file to magento/
- uncheck "Auto Generate (URL)", and set the path (first part of which is auto-generated) to /magento
- In the "common" tab, click "run" and "debug" for showing in the favorite menus.

Hopefully, the above will work for you...

3 comments:

Anonymous said...

"Name: Magento Server, URL http://127.0.0.1 (do NOT use localhost - I don't have notes on this, but I'm sure that I had trouble accessing the admin area using local host, and switching to http://127.0.0.1 fixed the problem)."

That is because cookies won't get set on a domain without a period in it (http://localhost/ has no period, while http://127.0.0.1/ does). For some reason it works in Opera if you HAVE to use localhost...

Nick said...

Thank you Rocinate! Your instructions for Zend Studio for Eclipse worked on magento! Usually this debugger just works out of the box when you setup the project, but for some reason I had to manually specify the settings using your instructions. Thank you!

Ed Eichman said...

I now use phpStorm, and was surprised how easy setting up debugging with xampp was. Might want to give phpStorm a spin some time.