Monthly Archives: May 2012

NetBeans Local History to the rescue

I did not realize the power of git reset. If you need to do a git reset on your working copy and you have modified (tracked, but uncommitted) changes, then git reset will blow away all your changes without warning.

To recover your changes:
If your IDE doesn’t do local backups, then your changes are lost forever. However, if you use NetBeans IDE, then you should have no problem recovering your lost changes. Ever since NetBeans version 6.x, by default it keeps 7 days work of file changes.

In order to view your file’s local history, make sure the file is open and click Team -> Local History -> Show Local History. NetBeans should give you a diff breakdown of your current file with previous teimd snapshots. Once you find the snapshot you want, right click the date and choose Revert from History.

Hope this helps!!

Enabling Xdebug for Acquia Dev Desktop

There are three essential tools I use in order to develop Drupal sites: Acquia Dev Desktop, NetBeans IDE, and Xdebug. Xdebug is a great tool to step through your code in order to troubleshoot a bug, however, it comes disabled by default on Acquia Dev Desktop. The following are instructions to enable Xdebug on Acquia Dev Desktop (ADD).

Note: although both ADD and Netbeans are cross-platform applications, these instructions are for Mac OS X. Windows and Linux instructions might differ slightly.

1) Start ADD and click the Settings… button

Acquia Dev Desktop

2) In Settings, click the Config tab

Acquia Dev Desktop Config screen

3) Click the Edit link to the right of PHP

4) After your text editor starts, look for the following line:

;zend_extension="/Applications/acquia-drupal/php5_3/ext/xdebug.so"

and replace with:

zend_extension="/Applications/acquia-drupal/php5_3/ext/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

5) Save the file and close the text editor

6) Click the OK button and restart the Acquia Drupal Stack

Once you have Xdebug enabled, you should now be able to step through your code on NetBeans. Here are the steps to verify Xdebug is working with NetBeans:

1) After you start NetBeans edit your project’s properties: File -> Project Properties

2) Under Run Configuration change the Project URL from the default URL to Acquia Dev Desktop’s URL (e.g. http://localhost:8082/)

NetBeans - Project Properties

3) Click the OK button

4) Start the project debugger, on the menu click Debug -> Debug Project

5) Look in the NetBeans status bar for netbeans-xdebug running

NetBeans Debugging Status Bar

6) Once xdebug is running, you can now step through your code by clicking the Step Through buttons

Netbeans debugger

You should now be stepping through your code. Feel free to step into functions and following the logica flow of your application. More information on PHP debugging with NetBeans can be found here:

http://netbeans.org/kb/docs/php/debugging.html

Happy Debugging!!!