Contact us

Setting up Aptana Studio 3 (IDE) for Drupal Development

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, 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, 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 AptanaIt is assumed that you're by now ready with a working installation of Aptana Studio. If you've not yet installed, go ahead installing & 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 are 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: http://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 AutocompleteThis I believe, happens automatically (since the code base of Drupal is within your Drupal projects). And it seems to work even when Drupal's code base is marked for "Exclude from build". For some reasons, if you can't  get autocomplete happening - you could try adding Drupal codebase as an external PHP library (either globally or in 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 AssistCode Assist helps us to auto-write some part 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 documentationThe "Drupal Ruble" plugin that we installed in 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 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 you need to select exact name of 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 Development:

  • Ability to auto-format a script (fix indendation issues in a bad written code in one shot)?
  • Ability to run drupal coder code-review and listing 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 :)

Comments

Permalink

You can "format code in one shot" out of the box with Eclipse. Once you have set up Aptana to format your PHP according to coding standards: Right Click -> Source -> Format. Or CMD-SHIFT+F when the file is open. Also, to save some time, one can use drupal.org/sandbox/kmadel/1249414 for quick adherence via an import of that XML file to the Aptana preferences. Great article!

Hi Kenny, Thanks for the tip. Though the built-in formatter doesn't seem to work out very well in some cases, it looks like a good start & I believe, we would have to use the "format" feature very rarely - eg: when trying to view a compressed CSS/JS file.

Also - Thanks for pointing to the sandbox project specific to the requirement (but, I'm more satisfied with the current setup).

Permalink

You have a tip here about automatic docblock creation in Aptana Studio 3. You say to create the function and then go to the line above and type /**+return. We are having a little trouble with this (you can see the question on stack overflow: http://stackoverflow.com/questions/16262933/generating-docblock-for-a-m…) and after doing a little research I found this is a feature of PDT and, as far as I can tell, not present in Aptana 3. Is this something that is added by the Drupal bundle? Can you tell me more about how it works for you/your environment? Thanks!

Hi Sarah, you're right. I presumed that the functionality would work in Aptana Studio, since it's based on Eclipse, which doesn't seem to be the case. I just removed the misleading section. Thanks for pointing it out.

Add new comment

The content of this field is kept private and will not be shown publicly.