blog-banner

Setting Up Aptana Studio 3 (IDE) for Drupal Development

  • Drupal
  • IDE

Aptana Studio 3

Aptana Studio is a complete package for an open-source Web Developer that works out of the box for the most. From autocomplete/IntelliSense, code validation, code assist, code debugging, and terminal access to version control - most activities can be accomplished in a single integrated environment. Being built upon Eclipse, it can be viewed as a web developer (HTML/CSS/JS/PHP/RoR/Python) version of Eclipse & even more than that. In fact, the studio is much faster, and sleeker than a stock Eclipse & should work fine on an average PC.

In case you're wondering if it will be a steep learning curve - to an extent, it may be. But the official documentation comes to the rescue & is an excellent guide to have a kick start.

Drupal Development on Aptana

It is assumed that you're by now ready with a working installation of Aptana Studio. If you've not yet installed it, go ahead install & getting used to it, before continuing. We suggest installing a "standalone" version as it's usually much faster & lighter on resources. Being a package that works out of the box, it's not much of a deal to tweak it for Drupal Development. I believe the documentation link above and/or the community can help resolve most of the queries of people new to Eclipse / Aptana Studio, so will cover the areas where I think there would be some tweaks required to the studio for Drupal development.

Drupal Code Standards

  • Go to Window->Preferences and look for "Editor" settings, ensure that the spacing/tab is as per Drupal Coding Standard Guidelines.
  • It looks like "adding a blank line" to the end of files - is not possible out of the box in Aptana Studio. So, we could use the eclipse plugin: "AnyEdit" (since Aptana is based upon Eclipse)
  • Follow the "Installation" instruction here: https://andrei.gmxhome.de/anyedit/ (In the "Install new Software" window, you will have to TICK only one package named "AnyEdit" and click "Finish" -- use the latest available version of AnyEdit)
  • Go the Window->Preferences and search for "AnyEdit", then CHECK the option: "Create new lines at the end of the file"

Drupal in-built functions / classes Autocomplete

This I believe, happens automatically (since the code base of Drupal is within your Drupal projects). And it seems to work even when Drupal's codebase is marked for "Exclude from build". For some reason, if you can't get autocomplete happening - you could try adding Drupal codebase as an external PHP library (either globally or at the project level).

To add Drupal as a global external PHP library, just extract drupal onto a folder; Go to Window->Preferences->Aptana Studio->Editors->PHP->Libraries and use "New user library".

Drupal Code Assist

Code Assist helps us to auto-write some parts of commonly written code. For example: filling the code required for a hook implementation with the click of a command. Aptana plugins (called "Aptana Rubles") comes to the rescue here. By default, the plugin for Drupal code auto-filling is not installed - but could be quickly installed as below:

  • Open up a PHP file in the editor
  • Right Click -> Commands -> Bundle Development -> Install Bundle and choose "Drupal" bundle & click "OK" - the rubles Drupal plugin will then be installed.
  • Now, to auto-fill common Drupal snippets (hooks & theme implementations - to be precise, for now): Open a .module file, right-click on the editor -> Commands -> Drupal -> Hooks/Theme, and the corresponding theme/hook implementation for that module will be auto written for you.

Drupal API documentation

The "Drupal Ruble" plugin that we installed in the previous step does more than code assist. It can help us quickly get the Drupal API documentation for any API method.

Just select the region of API code (implementation) for which you want the API documentation - then press Ctrl+H (or right-click -> Commands -> Drupal -> Documentation for Selection). It's so convenient when you want to quickly refer to the API documentation of something you're writing without having to go through an additional Google Search (or Drupal API search).

The good thing is that the "Documentation for Selection" (that was just explained) is intelligent enough to bring up the API documentation for hook_block_info (say) - if you select a word: "{module_name}_block_info" and use the documentation for selection (Ctrl +H)... Not necessarily do you need to select the exact name of the API function?

Some Advanced Possibilities (Ideas)

I haven't tried these myself, but I believe it should be possible for one to do the following for automating even more of our day-to-day activities involved in Drupal web Development:

  • Ability to auto-format a script (fix indentation issues in a badly written code in one shot)?
  • Ability to run drupal coder code-review and list possible issues to fix automatically?
  • Ability to run PHP unit test on modules from within the studio, with simple shortcuts?

Questions/suggestions about this? Feel free to let me know through your comments below. Happy coding :)

Get awesome tech content in your inbox