Configure Local Development environment (Netbeans) for php (Drupal) debugging

By John Bowen, 11 August, 2009

I have several Drupal (php/mysql) sites in production, and several more on my local development machine. I've had plenty of experience moving sites from the dev machine to a production server, but recently ran into a different problem. I needed to move an exact copy of a production Drupal 5 site to the local machine (running the XAMPP stack), and be able to debug the code to find a problem with a specific Drupal module. Here is the path I followed:

First, follow [this script|http://wiki.netbeans.org/HowToConfigureXDebug] to get XDebug installed and configured on XAMPP.

Download (FTP) the entire site to my local machine (under 'C:\xampp\htdocs\clientName'). This should make it accessible on the local machine as 'http://localhost/clientName'.

I needed to download the database too, because firewalls were preventing the connection from my local (web) server to the production database server...and I didn't want to muck with the production database anyway.

Create a new, empty database on the local machine's server, with a user/password combination to use for testing/development.

Change the settings in the 'default' site folder (C:\xampp\htdocs\clientName\sites\default\settings.php) to match the local machine's database (and not the production database).

Use phpmyadmin on the production server to 'Export' the entire database and its data to a file. Use the matching 'Import' feature on the local machine's phpmyadmin to populate the database. After three unsuccessful tries (out of memory errors that crashed Apache), I realized I needed to Export to a file, and let it use zip compression. Even then, it took two tries to complete the whole Import (phpmyadmin happily 'resumes' the Import after the timeout...very slick).

I started getting 'out of memory' errors at this point. [This article|http://drupal.org/node/283579] pointed out that a change in the memory_limit in php.ini (and an Apache restart) was all I needed.

I found that Drupal's 'clean urls' were broken. I couldn't get past the site's front page. [This tip|http://drupal.org/node/43545] cleared that up (the mod-rewrite change suggested there did the trick).

I started up NetBeans, and created a 'new PHP project from existing source', pointing it to my site's folder (C:\xampp\htdocs\clientName). Debugging just magically worked from NetBeans, as long as I Run/Debug the project from within the Netbeans IDE. I could set break points and 'watches' to see what's happening as the pages load.

By default, xdebug was breaking on the first line in the first file loaded, which got annoying pretty fast. I found [this article|http://forums.netbeans.org/post-37208.html] that fixed that in a jiffy.

Voila! Everything works! I'm debugging php apps from within the Netbeans 6.7 IDE.

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.