What is the best way to auto generate getters and setters for a class in php?
Have you looked at the __set and __get methods? Don't know if this is what you mean but the are automatically called whenever a class member is SET or Retrieved/Fetched/Accessed.
With Eclipse go to Preferences -> PHP -> Editor -> Templates -> New and use something like this:
/**
* Method to get the ${PropertyName}
*
* @return ${ReturnType} return the ${PropertyName}.
*
* @since __DEPLOY_VERSION__
*/
public function get${MethodName}() {
return $$this->${PropertyName};
}
/**
* Method to set the ${PropertyName}
*
* @return boolean True on success and false on failed case
*
* @since __DEPLOY_VERSION__
*/
public function set${MethodName}($$value) {
$$this->${PropertyName} = $$value;
}
To use the template type its name and press ctrl+space - a context menu should also automatically appear when you type the name.
Zend Studio has a feature of automatic getter/setter generation.