File and Code Templates
PhpStorm creates files using file templates as described in File templates. Use this page to view, edit, and create such templates .
Scheme | Select the scope to which the file templates apply:
|
Tabs
PhpStorm includes the following types of templates:
Files | PhpStorm uses file templates to create new files. |
Includes | These are templates for reusable fragments that can be included in file templates. For more information, refer to Reusable content in templates. PhpStorm provides a set of predefined built-in templates for generating PHP file headers and PHPDoc comments for PHP classes, fields, and functions (methods). |
Code | PhpStorm uses these built-in templates as snippets to generate various constructs. You can edit the templates available on this tab to modify how PhpStorm generates these constructs, but you cannot create new ones. To create custom code snippets, use live templates. |
Toolbar
Create Template | |
Create Child Template File | Add a child template to the selected template to create a set of multiple files with one template. |
Remove Template | Delete the selected file or include template. You can delete only custom templates, not the default ones. |
Copy Template | |
Revert to Original Template | Revert the selected template to its original state. You can revert only modified default templates. |
Template settings
Name | Specify the name of the template to display in the UI. Not available for default built-in templates. |
Extension | Specify the file extension to associate the template with a specific file type. Not available for default built-in templates. |
File name | If necessary, specify a name for the file created from this template. By default, PhpStorm prompts the user to enter a name when adding the file. You can hard-code a specific name to avoid the prompt entirely, or compose a template from available variables. For example, here is how you can use the specified name but put it one directory above the one that was selected during file creation: Not available for default built-in templates. |
Template editor | Edit the code used for the selected template. For more information about the syntax used in file templates, see Syntax. |
Reformat according to style | Reformat the contents generated based on this template according to the code style defined for this file type. This option is available only for file templates. |
Enable Live Templates | Insert live templates inside the file template. Use the Velocity escape syntax to include live template variables in a file template, for example: |