Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent PhpStorm from reassigning file types?

Tags:

phpstorm

I am currently evaluating PhpStorm as an alternative to Aptana Studio, we use right now. But one issue really annoys.

We use the *.tpl file extension for our PHP templates. This file type is usually mapped to Smarty. It was quite easy to set this to "PHP files (PHP)". But each time I restart PhpStorm, I get this message:

File type recognized: File extension *.tpl was reassigned to Smarty

So it maps the file type back to Smarty. If I try to "Revert" it through the "Event log", it will than map it to "Text files" but not back to PHP.

So, how can I prevent PhpStrom from touching my manual changes are keep the mapping to PHP (and not to Smarty)?

like image 219
2ndkauboy Avatar asked Oct 01 '22 19:10

2ndkauboy


1 Answers

So the following method would work:

Without touching the configuration:

  1. Change the file type mapping through the Preferences > Editor > File Types setting
  2. Restart PhpStorm
  3. As soon as the "File type recognized" message appears, click the "Revert" links (see question)
  4. Redo step 1

Now PhpStorm should not map it back again.

With touching the configuration files:

In your user profile, you should have a folder .WebIde70/config/options (or something similar) and there you should have a file called filetypes.xml (if not create an empty one), where you can set the mapping and prevent PhpStorm from reverting it. Here is a simple example with only the mapping for my question:

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="FileTypeManager" version="11">
    <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;" />
    <extensionMap>
      <mapping ext="tpl" type="PHP" />
      <removed_mapping ext="tpl" approved="true" type="Smarty" />
    </extensionMap>
  </component>
</application>

As you can see, the settings file not only sets the new mapping, but also removes the original mapping for the Smarty template.

like image 149
2ndkauboy Avatar answered Oct 04 '22 21:10

2ndkauboy