I've been using ActiveState's Komodo for a few weeks now in response to my frustrations with Eclipse. As with any IDE there was a short relearning of my ways that was necessary, but I am happy to report that I really like this IDE. The last bit of functionality I've been wanting to tie together is directly related to debugging Drupal in Komodo. Here's the steps that I took to get a Drupal development environment with debugging in Komodo on a clean installation of a 64bit Ubuntu 8.04.
A good deal of this may be redundant if you already have your environment established, but it is recorded here nonetheless to help others become proficient at what we do. While I prefer command line interfaces I am going to lean towards providing gui tools to allow newer devs options. If you don't need or want all of the minute details skip to step 6 and get straight into configuring for debugging.
There are two primary methods for installing the necessary packages. The first is by using the Synaptic Package Manager install the following packages (I've included descriptions for those not familiar with the packages):
apache2 - Apache v2 is the next generation of the omnipresent Apache web server. This version - a total rewrite - introduces many new improvements, such as threading, a new API, IPv6 support, request/response filtering, and more.
mysql-server-5.0 - MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query language in the world. The main goals of MySQL are speed, robustness and ease of use.
mysql-client - This is an empty package that depends on the current "best" version of mysql-client (currently mysql-client-5.0), as determined by the MySQL maintainers. Install this package if in doubt about which MySQL version you need. That will install the version recommended by the package maintainers.
mysql-gui-tools-common - Icons and GUI XML files used by MySQL Administrator, Query Browser and other tools in the MySQL GUI Tools suite. This package also includes documentation files.
phpmyadmin - phpMyAdmin is intended to handle the administration of MySQL over the WWW.
php5-common - This package contains the documentation and example files relevant to all the other packages built from the php5 source.
php5-cgi - This package provides the /usr/lib/cgi-bin/php5 CGI interpreter built for use in apache 2 with mod_actions, or any other CGI httpd that supports a similar mechanism.
php5-cli - This package provides the /usr/bin/php5 command interpreter, useful for testing PHP scripts from a shell, or perhaps even performing general shell scripting tasks, if you're frightened of perl and python.
php5-curl - CURL is a library for getting files from FTP, GOPHER, HTTP server.
php5-gd - This package provides a module for handling graphics directly from PHP scripts. It supports the PNG, JPEG, XPM formats as well as Freetype/ttf fonts.
php5-mcrypt - This package provides a module for MCrypt functions in PHP scripts.
php5-mysql - This package provides modules for MySQL database connections directly from PHP scripts. It includes the generic "mysql" module which can be used to connect to all versions of MySQL, an improved "mysqli" module for MySQL version 4.1 or later, and the pdo_mysql module for use with the PHP Data Object extension.
php5-tidy - This package provides a module for tidy functions in PHP scripts. Tidy is an extension based on Libtidy (http://tidy.sf.net/) and allows a PHP developer to clean, repair, and traverse HTML, XHTML, and XML documents -- including ones with embedded scripting languages such as PHP or ASP within them using OO constructs.
php5-xdebug - Provides extensive debugging utilities for PHP.
ruby - Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in perl). It is simple, straight-forward, and extensible.
cvs - CVS is a version control system, which allows you to keep old versions of files (usually source code), keep a log of who, when, and why changes occurred, etc., like RCS or SCCS. Unlike the simpler systems, CVS does not just operate on one file at a time or one directory at a time, but operates on hierarchical collections of directories consisting of version controlled files.
subversion - Subversion, also known as svn, is a version control system much like the Concurrent Versions System (CVS). Version control systems allow many individuals (who may be distributed geographically) to collaborate on a set of files (typically source code). Subversion has all the major features of CVS, plus certain new features that CVS users often wish they had.
scim-qtimm - SCIM (Smart Common Input Method) is an input method (IM) platform. This package brings functionality similar to the immodule for GTK+ to the Qt library. The main goal is to extend and enhance the input method support in the Qt library, in order to provide a modern and powerful multi-language input system.
scim-tables-additional - This package contains SCIM input method data tables for non-CJK languages. The currently supported languages are Amharic, Arabic, Nepali, Russian, Thai, Vietnamese, and several Indic languages (Bengali, Gujarati, Hindi, Kannada, Malayalam, Punjabi, Tamil and Telugu). It also provides support for X-SAMPA and LaTeX style input.
tcl8.3 - Tcl is a powerful, easy to use, embeddable, cross-platform interpreted scripting language. This package contains everything you need to run Tcl scripts and Tcl-enabled apps. This version does not support threads; if you need thread support, please use tcl8.4.
The second method can be initiated from a command line prompt with the following and selecting Yes where prompted:
sudo apt-get install apache2 mysql-server-5.0 mysql-client mysql-gui-tools-common phpmyadmin php5-common php5-cgi php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-tidy php5-xdebug ruby cvs subversion scim-qtimm scim-tables-additional tcl8.3
During the install process you will be presebted with a screen asking you to pick the Web Server to configure for use with phpMyAdmin. Selecting apache2 by hitting the space bar and tabbing the ok button is the way to go. You will also be prompted to enter a mysql root password in a similar fashion.
At this point you can navigate to http://localhost/ to see a lovely It works! on the screen. At this point, I'd like to challenge windows to make this process easier ... ok enough sarcasm for now.
Configure Apache - This step is largely personal preference. I wrote a blog posting a few days ago entitled Dev Friendly Apache Configuration for Drupal. You can perform this step any way you want as long as it works. For the purposes of this tutorial I'm going to replace the existing conf file at /etc/apache2/sites-enabled/000-default with the conf file in that tutorial. I'm going to leave the file as is which means that our drupal installation from this tutorial will be available at http://mysite/
Next we will want to adjust the permissions on the /var/www. You will need to know your username for this step. Simply type whoami at a command prompt then use that response in this command:
sudo -R chown username.username /var/www
Replace username in the command with your username.
Reading the virtualhost entry shows that we have our host pointing to a specific directory. You can create that directory by using the following:
mkdir -p /var/www/mysite/trunk/htdocs
Next we need to edit the host file to include a mysite entry as outlined in the Apache configuration tutorial.
From there we need to enable the mod_rewrite module for Apache and reload the configuration by issuing the following commands:
sudo /etc/init.d/apache2 reload
*whew* You can now access http://mysite
Install Komodo - Activestate's Komodo is an awesome tool. The trial version will last for 3 weeks and should be sufficient for you to determine if you agree with me or not.
When you download the trial version of the software for Linux you will be presented with two choices depending on the libstdc libraries installed. The version of Ubuntu I'm using has the libcpp6 version so I downloaded the package labelled AS package (libcpp6) . In order to find out which version you will need run the following command:
find /usr/lib -name libstdc*
If you find entries for "/usr/lib/libstdc++.so.6", use libcpp6. If you find entries for "/usr/lib/libstdc++.so.5", use libcpp5. If you have both entries you can choose either one, but the suggestion is the more recent libcpp6.
Activestate provides comprehensive installation instructions ... so we'll skip over the details and rely on you to follow them. If you've been following this tutorial from the beginning you will already have everything necessary for the installation.
Check Your Configuration - Start the Komodo IDE and read the Start Page you are presented with. You should see a link titled Check Configuration. Click the Check Configuration link and you should see that each of the supported feature sets are ready for use with the exception of Perforce. If you want Perforce working then feel free to write your tutorial. If something is not working, use the help links in the window to find additional information and double check that you've followed everything in this tutorial so far.
One of the first things I like to do with Komodo is enable the sidebar by going to View >> Tabs >> Projects
Install Drupal - here's where I get lazy ... Drupal has an excellent documentation team that has been working hard to provide you what this tutorial would normally need to cover. http://drupal.org/getting-started/6/install is an excellent resource for a Drupal 6 installation while http://drupal.org/getting-started/5/install is good for a Drupal 5 installation. I installed my version of Drupal in /var/www/mysite/trunk/htdocs so that when I browse to http://mysite/ I see a Drupal website.
Configure Debugging - This is the bit that took me a little while to figure out. Each set of instructions I had found seemed to walk you from the very beginning all the way up to the debugging bit. However, because of the packages we just installed and the nature of Ubuntu we can skip a lot of what they describe because it is already in place and configured. The "It just works" mentality can be applied here. The xdebug configuration file is located at /etc/php5/apache2/conf.d/xdebug.ini and we need to add the following lines to the end of it:
Restart Apache to enable your changes:
sudo /etc/init.d/apache2 restart
By default Komodo will listen for debugging requests on the lowest available port so we need to tell it to stay listening to the port we designated in xdebug.ini. In Komodo select the menu item Edit >> Preferences to open the preferences window. Expand the meu tree on the left so that you are looking at the options for Debugger >> Connection and select the radio box to specify a specific port. The number 9000 should already be entered, but if it is not go ahead and enter it. Click OK to exit this window saving your changes. You now have working debugging set up. For those of you that lack patience you can simply append the XDEBUG_SESSION_START variable to a local url and continue on your own ... an example url would be:
Configure URL Mappings - The example dev site we set up in this tutorial is visible at http://mysiste/ ... we now need to tell Komodo to map the local files we work with to that url so that as we debug we can edit the files. If we do not perform this step Komodo will still display the files, but they will be read only versions. Open the menu item Edit >> Preferences again and this time select the Mapped URIs option. Click the Add Button which is a green circle with a plus sign. Following our tutorial, you will enter the URI as http://mysite/ and the Maps To can be selected by entering /var/www/mysite/trunk/htdocs/. Clicking OK twice exits the preferences window saving your changes. Using Mapped URIs you can have as many virtual hosts to develop against as your machine will hold simply by following the instructions in this tutorial.
Cool Tricks - This part isn't necessary, but if your using Firefox the Xdebug Helper Addon is an excellent resource for those that, like me, appreciate not having to remember everything. You simply click it to append or remove the XDEBUG_SESSION_START=1 variable from your requests.
This blog post has reached my limit for overly lengthy posts, but I think it covers good information and was worth the effort. The next post I write will be about how to actually use the debugger to resolve a specific problem in Drupal that we will create. Oh yeah and if anybody from ActiveState actually reads this I sure wouldn't mind if there was some way to slip me a license for all the blogging < grin >