Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (43 sloc) 1.55 KB
A time-saving device for creating getters & setters in PHP classes
Based on a snippet originall published by @akrabat:
In your PHP class, simply type the following:
php-getset<TAB><name of your property without a $ sign>
Sublime Text will add the getter and setter to your class, and
name them after your property.
For example, if your property is called $connection, you would
go into your class, and type:
and Sublime Text will create getConnection() and setConnection()
methods for you.
* ${2:[description here]}
* @return ${3:[type]} ${4:[description]}
public function get${1/(.*)/\u$1/:[ Prop name ]}() {
return \$this->${1:[ Prop name ]};
* ${5:[Description]}
* @param ${3/(.*)/\u$1/:[type]} \$new${1:[ Prop name ]} ${4/(.*)/\u$1/:[description]}
public function set${1/(.*)/\u$1/:[ Prop name ]}(\$${1/(.*)/$1/:[ Prop name ]}) {
\$this->${1:[Prop name ]} = \$${1/(.*)/$1/:[ Prop name ]};
return \$this;
<!-- Optional: Tab trigger to activate the snippet -->
<!-- Optional: Scope the tab trigger will be active in -->
<!-- Optional: Description to show in the menu -->
<description>Create getter and setter methods</description>
Something went wrong with that request. Please try again.