Debugging Magento Code with Net Beans IDE

Sunday, September 23, 2012

Mostly people are aware of how the xdebug is used on debugging PHP applications. However there can be people out there, alone, killing their eyes trying to find out which class called which functions etc. Here is a quick tip for you! Especially if you are trying to find your way with Magento!

NetBeans is a great IDE with it’s support to PHP!By using NetBeans and xdebug, we can freely and easily debug our PHP applications. However as the web evolved, there are not anymore php files to debug but there are “user friendly” urls to debug. So you cannot give the filename to NetBeans and say debug! because most of the web applications out there are now MVC based as this is the new trend in the PHP world. MVC means, one file -index.php dispatches all the requests. So how to debug using friendly urls.

Well you can use your NetBeans IDE to listen requests coming from your browser. That’s what NetBeans does when you click on debug button, which opens the start page (index.php) with a get variable like: ?XDEBUG_SESSION_START=netbeans-xdebug. This value (netbeans-xdebug) can change from your NetBeans configuration (click on preferences and choose the PHP tab). When this parameter is given, you can send any request to the NetBeans and it will listen!

All you need to do:
1. Start the debugging session on clicking Debug button
2. Continue until the end of the script however do not finish the debugging session by clicking on the Stop button.
3. On your browser, write the url you want (http://localhost/magento/customer/account/login/)
4. Add your own debugger identifier to the end of it like:
index.php?XDEBUG_SESSION_START=netbeans-xdebug (For magento use http://localhost/magento/customer/account/login/XDEBUG_SESSION_START/netbeans-xdebug, notice that I’m first adding the key and value next to the end of the url)
5. Check your NetBeans to see that your new request is already started to be debugged! Now you can walk around the code and debug it anyway you like it.

2 comments:

  1. Its good information about magneto. I am thinking about new website and now i will use this platform. Thanks for informative post.

Post a Comment