Configuring Aptana for Drupal development

Integrating Drupal into Aptana for a better developer experience.

Configuring Aptana for Drupal development

For a long time, it has been the holy grail of web development IDE's to have perfect integration into the system you are working on at the time. For me, this means doing Drupal development and having features of:

  • Correct syntax highlighting (Aptana default)
  • Syntax validation inline whilst typing (Aptana default)
  • Drupal hook autocomplete suggestions
  • API documentation for both PHP and Drupal (Aptana does PHP by default, not Drupal)
  • jQuery syntax highlighting (Aptana default)
  • CSS syntax highlighting (Aptana default)
  • Git Version control aware
  • Easy to read font
  • Easy to read colour scheme and contrast

As you can see, Aptana fulfills most of the base requirements, we just need to add some extra pieces to taylor it to suit our needs.

Drupal hook autocomplete suggestions

Having the ability to autocomplete hook functions is key to creating modules and themes rapidly, and without time-wasting typos. Fortunately there exists a ruble for Drupal hooks under Drupal 7.

Installation

mkdir -p ~/Documents/Aptana\ Rubles/ 
git clone https://github.com/HollyIT/Drupal-Bundle-for-Aptana.git ~/Documents/Aptana\ Rubles/Drupal-Bundle-for-Aptana/

This should take effect immediately, allowing you to now autocomplete Drupal hooks. For example, in a module file, type

'hook_form' - you should see an autocomplete dropdown appear allowing you to choose the Drupal API hook to implement.

Selecting the hook will prepopulate the neccassary code into the module, including the comment at the top.

<?php
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function pixelite_theme_form_BASE_FORM_ID_alter(&$form, &$form_state, $form_id) {

}
?>

Drupal API documentation

The above ruble also builds an internal link to the drupal.org API documentation. This enables you to inspect any core Drupal API function and open the API documentation page for it. Simply:

  1. Highlight the whole function
  2. Right click -> Commands -> Drupal -> Documentation for selection

Or alternatively use 'Ctrl + H'

Git Version control aware

Having git integration is also a must have, as often something as simple as knowing what branch you are working on right inside your IDE can make a big difference. You can also make and push commits from within Aptana, I choose to still do this on a seperate terminal, but it can also be accomplished completely from either the GUI, or built-in terminal in Aptana as well.

Installation

As with all Eclipse plugins, navigate to

  1. Help -> Install new software

Enable the Eclipse update site

  1. Click 'Available software sites'
  2. Check 'Eclipse Indigo Update Site'
  3. Click OK
  4. Click Work with 'All Available Sites'

Now if you search for git, you should see the 'Egit' plugin be available, check this, and finish installing the plugin through the wizard interface.

Once the plugin has finished installation, Aptana will prompt you to restart, do this. When Aptana is back you will have a new perspective available - 'Git Repository Exploring'.

Easy to read font

My personal favourite mono-spaced font on Ubuntu is Inconsolata and can easily be installed by

sudo apt-get install ttf-inconsolata

There are a number of other good choices as well, let me know what font you like to use in the comments.

In order to get Aptana to use the font, you need to

  1. Navigate to Window -> Preferences
  2. Expand Aptana Studio -> Themes

Here you can select the font desired. The screenshot shows my selection:

Easy to read colour scheme and contrast

Again this is a personal preference item here, Aptana ships with a whole host of themes out of the box you can choose from, and for the most part they are fairly decent. I even quite like the default 'Aptana Studio' theme.

But the above all changed after I read http://ethanschoonover.com/solarized which goes on to talk about the reasons behind the colours choosen, and why they are better for your eyes. I would recommend the read. In any case, some nice people have thrown together an Aptana theme for us to use which makes use of the above solarized colour scheme.

Firsly, clone the git repo down

mkdir -p ~/projects/Aptana-Solarized/
git clone https://github.com/bueltge/Aptana-Solarized.git ~/projects/Aptana-Solarized/

Then let Aptana know about the new themes

  1. Navigate to Window -> Preferences
  2. Expand Aptana Studio -> Themes
  3. Import the new themes (there are two)

I find the light theme works really well during the day, and the dark theme is perfect for the laptop when coding at night

Final thoughts

Well everyone, that is how I like to code Drupal projects inside Aptana, let me know if you have anymore tips and tricks that may be of some help to me or to others reading this post.

Thanks