Customizing a Netbeans Template

Customizing the Netbeans 5.6.1 PHP Template is easy.

Under Tools/Templates you find the Template Manager. There you can customize the templates for PHP classes and interfaces. In my case I prefer the date given in the PHPDocs in the following format: “2009 Jun 25″. The ${date} variable is a String. Casting this into date type, the output can be formatted according to java.text.SimpleDateFormat, in my case ${date?date?string(“yyyy MMM d”)}.

To change the user name, edit User.properties under Tools/Templates/User Configuration Properties:

user=Code-Kobold (Ron Metten) (www.code-kobold.de)

The template now looks like this:

<?php
/**
 * Description of ${name}
 *
 * @author ${user}
 * @since ${date?date?string("yyyy MMM d")}
 */
 class ${name} {
 } // class ${name}
?>

This generates the following output, when a new PHP Class is created:

<?php
/**
 * Description of Template
 *
 * @author Code-Kobold (Ron Metten) (www.code-kobold.de)
 * @since 2009 Jun 26
 */
 class Template {
 } // class Template
?>