Drupal coder: configuring Zend Studio PHPDocumentor extension for Drupal

Submitted by Frederic Marand on Fri, 2006-03-17 20:10

Zend Studio is a convenient environment to code in PHP, which is why many Drupal developers are using it. But some settings are necessary to ease its use, due to the specific extensions Drupal uses.

Recognizing Drupal components within the Studio IDE

First things first, chances are you've already noticed Zend Studio didn't consider Drupal .module, .inc, or .theme files to be "Web documents", or even actual PHP, and found how to configure it for them. If you haven't, it's real simple (example given for Zend Studio 5.0.0) :

  1. Start Zend Studio
  2. Open the ToolsPreferences dialog
  3. Choose the File Types tab
  4. Choose the PHP files in the top left list
  5. Click Add on the top right button, near the File type extension list
  6. Add each extension needed by Drupal: module, inc, engine, theme, one at a time. Do not include the dot before the extension
  7. That's it ! You now have access to the full features of the Zend Studio IDE on Drupal components

Generating PHPDocumentor documentation for Drupal components

Zend Studio 5.x comes bundled with PHPDocumentor and some integration work done. while PHPDocumentor is not the standard documentation tool for Drupal, which uses DOxygen instead, it is still very convenient, notably as most tags are compatible between the two systems anyway.

However, Studio does not reconfigure the PHPDocumentor file types, so when you try and generate documentation using Zend Studio's ToolsPHPDocumentor wizard, you'll stumble on this error:

PHPdocumentor: not a PHP File

This time the workaround is not within Zend Studio itself: although Zend could have integrated this setting into PHPdocumentor, they didn't do it (yet ?) in version 5.0.0. The setting is located in file <studio directory="">/bin/phpdocumentor/phpDocumentor.ini</studio>. You can just as well edit it within the IDE while it's up. You'll find it's a vanilla .ini file, with the files to be processed as PHP source listed in a _phpDocumentor_phpfile_exts section:

(...skip beginning of file...)
[_phpDocumentor_phpfile_exts]
php
php3
php4
phtml
(...skip rest of file...)

All it takes is to add the extensions we need:

(...skip beginning of file...)
[_phpDocumentor_phpfile_exts]
php
php3
php4
phtml
engine
inc
module
theme
(...skip rest of file...)

That's it ! You can now generate docs for your Drupal code from within Zend Studio. Don't forget to add the comments into your code, now !

Leticia Larrosa (not verified)

Thu, 2008-05-29 05:50

Follow the previous steps, to recognizing Drupal components with Zend Studio for Eclipse you can:

1- Open the Window → Preferences dialog
2- Choose General → Content Types on left list
3- Choose Text → PHP Content Type in the top rigth list
4- Click Add on the top right button, near the File type extension list
5- Add each extension needed by Drupal: *.module, *.engine, *.theme, one at a time.

Regards

Zend Studio for Eclipse is a great environment for developing Drupal, especially now I've got debugging working locally and FTP sync using Aptana.

Does anyone know how to get the Drupal API included in code completion? I'm gonna look into it but if the reseacrh has always be done...

cheers

Marcus

It is available as soon as you create your project from the root of your (multisite) install, just like in PDT and Aptana.

The problem is that in that case you are not working remotely but locally, and syncing to the remote. But it is indeed convenient to have the whole API in autocompletion in Studio.

This being said, I tend to prefer working with the "classical" version of Studio, which can manage remote projects transparently, including autocompletion. Your Zend Studio for Eclipse normally allows you to use the classical IDE too, if you want to try it.