Eclipse/ZendStudio Custom Username for Code Templates

At work we started using Zendstudio, as the installation on our Linux Boxes is global, we can’t edit the ZendStudio.ini, and the only way to specify our custom username for Code Templates is using the commandline arguments. The easiest way is to create a shell script to start ZendStudio:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/bin/bash

###### CONFIG ######
ZENDPATH="/opt/ZendStudio/ZendStudio"
USERNAME="Marco Neumann"
USERMAIL="email_at_binware_dot_org"
####################

USERSTRING="$USERNAME"
if [ ! -z $USERMAIL ]; then
    USERSTRING="$USERSTRING <$USERMAIL>"
fi

$ZENDPATH -vmargs -Duser.name="$USERSTRING"

Now ZendStudio will replace the variable ${user} in your Code templates with Marco Neumann <email_at_binware_dot_org>

Here is an example for “Simple php file” in ZendStudio (You will find it in ZendStudio under Window/Preferences/PHP/Code Style):

  • Code Template

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    <?php
    /**
     * File for the class ${file}
     *
     * @category   CATEGORY
     * @package    PACKAGE
     * @subpackage SUBPACKAGE
     * @copyright  Copyright (c) ${year} ${user}
     * @author     ${user}
     * @version    $$Id:$$
     */
     
    /**
     * SHORT_DESCRIPTION
     *
     * LONG DESCRIPTION
     *
     * @category   CATEGORY
     * @package    PACKAGE
     * @subpackage SUBPACKAGE
     * @copyright  Copyright (c) ${year} ${user}
     */
    ${cursor}
  • Ouput

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    <?php
    /**
     * File for the class test.php
     *
     * @category   CATEGORY
     * @package    PACKAGE
     * @subpackage SUBPACKAGE
     * @copyright  Copyright (c) 2011 Marco Neumann <email_at_binware_dot_org>
     * @author     Marco Neumann <email_at_binware_dot_org>
     * @version    $Id:$
     */
     
    /**
     * SHORT_DESCRIPTION
     *
     * LONG DESCRIPTION
     *
     * @category   CATEGORY
     * @package    PACKAGE
     * @subpackage SUBPACKAGE
     * @copyright  Copyright (c) 2011 Marco Neumann <email_at_binware_dot_org>
     */

This also works with Eclipse and I think it would also work with Netbeans, but haven’t tested it.


Google +1 for Sharedaddy
SimpleXML vs XMLWriter vs DOM
comments powered by Disqus