PHPStorm different file templates for every new project?

Hey everybody,

Currently I'm working on a couple of projects (not related with each other).
Whenever I need to create a file from template I start wondering if that template was the right one...
I'm wondering if there is a way to set file templates per project ? A plugin, maybe ?

Thanks in advance,

Comment actions Permalink

This is not available - "file templates" is a per-IDE-instance setting.
You can file a feature request, however we do not plan to work on this very soon.

Comment actions Permalink

I was having this same annoyance and came up with somewhat of a solution. Stumbled on this post and figured I'd share:

Basically, I created a file in the includes section named "Project.php". In there, I set any variables that are specific to the project at hand. So for my current project for instance, I have:

#set( $PROJECT = "KoDeploy" )
#set( $DESCRIPTION = "TODO: ..." )
#set( $CATEGORY = "TODO: ..." )
#set( $CONTROLLERPREFIX = "Controller_" )
#set( $MODELPREFIX = "Model_" )
#set( $BASECONTROLLER = "Kohana_Controller" )

And then, at the top of all my file templates, I have the following:

#parse( "Project.php" )
#set ( $CLASSNAME = ${NAME.substring(0,1).toUpperCase()} + ${NAME.substring(1)} )
#set ( $PROJECT = ${PROJECT} )
#set ( $CATEGORY = ${CATEGORY} )
<?php defined('SYSPATH') or die('No direct script access.');

I set the variables to themselves in the main template file as well, because if you don't, the IDE will continue to prompt you for those variables (though if you leave them blank, it will use whatever's in Project.php

Not much of a solution, but it does allow you to edit just one file when you start a new project.

Comment actions Permalink

Hello tftd,

Please vote -

Thank you for feedback!


Please sign in to leave a comment.