Sunday, July 12, 2009

Generating getter/setters for PHP classes in eclipse

We need to add this php code template
function get${field} () {
 return $$this->${fieldVar};
}

function set${field} ($$${fieldVar}) {
 $$this->${fieldVar} = $$${fieldVar};
}

Goto
Window > Preferences > PHPeclipse > PHP > Templates > Click New


Fill up the form as shown in the screenshot below.


Now in ur class file just type "gett" and then CTRL + SPACE. We now have getter/setter template for php classes inside eclipse.



I have tested this using eclipse v3.3.1.1 and phpeclipse v1.2.0.200807220603NGT