The Generate command
Often, a lot of development time is consumed doing nearly useless work such as generating getters and setters for a number of fields in our classes. While these getters and setters may be needed for our code, it's a time-consuming job to write them all. Copy-paste-adapt bugs are right around the corner for this type of code, too. Luckily, you can have PhpStorm generate code for you by using the Generate command.
We can use the context menu or Alt+Insert (CMD-N on Mac OS X) in the Project Tool Window or the Navigation Bar to generate a file from a template. Some of the templates, like PHP Class, will open a dialog where we can specify some additional code generation options.
When we click OK, the IDE will generate a new file for us and, depending on the selected template, generate boilerplate code.
Generating Code in the Editor
We can also generate code within the editor. Pressing Alt+Insert (CMD+N on Mac OS X) in the editor will give us a list of all available code generation options.
Let's generate getters and setters. We can select the fields we want to generate them for.
After we click OK, PhpStorm will generate the code for us, including PHPDoc blocks and so on.
Live Templates and Surround Templates
When we press TAB, we can loop through the various placeholders and provide a meaningful value for them.
Using this technique, we did not have to write out the HTML tag. Instead, we could just use a Live Template (input:t in this case) and tab through some placeholders.
'Surround With' Templates work in a similar way: we can select a portion of code and press Ctrl+Alt+T (Alt-CMD-T on Mac OS X) and select a template we want to wrap our code in.
Emmet (Zen Coding)
When working in HTML or CSS, we can use Emmet (formerly known as Zen Coding) to generate tags for us. Try entering the following in an HTML document:
When we press TAB, PhpStorm expands the Emmet abbreviations into full HTML (or CSS):