28

I have several file extensions, like .module, that I would like to be understood by Eclipse to be PHP - so I get the same syntax highlighting, code completion, etc features as I would if I were editing a .php file. How can I do this?

I went to Window >> Preferences >> General >> File Associations and added *.module to the file types list. When I click on *.module, it now says the associated editors are the PHP Editor and the Text editor.

However, when I open the *.module file to edit it, it gives me an error message:

Unsupported content type in editor. To associate a file extension with a supported content type, please see the Content Types Preferences Page.

What am I doing wrong?

fixed: restarted Eclipse, and now it works.

4 Answers 4

43

Head to Window -> Preferences. Drill down to General -> Editors -> File Associations. From here you can add your extensions (e.g., *.module) and associate them with your preferred PHP editor.

Then restart Eclipse for the change to take effect.

Sign up to request clarification or add additional context in comments.

5 Comments

I've tried this, yet I think I'm still doing something wrong (see above.)
you have to restart eclipse after doing this for the fix to take
I had to do both the General->Editors->FileAssocations edit AND the General->ContentTypes edit. However, ContentTypes does not list a PHP Content Type (in Juno). Instead, I found the various PHP file extensions preset in the Text->%content-type.name.() option. This is where I added *.i to associate the old *.i files that I needed to be associated with the PHP Editor. Also, I had to restart Eclipse.
also make sure when you close Eclipse that you don't have any of your .module files open.
I've did it by "Refreshing" project. Then is when Eclipse recognizes file type due extension
16

FYI.

window > preference > general > content types.
Expand '▷Text' and you will find 'PHP Content Type'. Select that.
Then click 'Add' and insert your own extension.

3 Comments

The accepted answer did not work for me, but this did work. Using *.phpm file extension.
I had to do both the General->Editors->FileAssocations edit AND the General->ContentTypes edit. However, ContentTypes does not list a PHP Content Type (in Juno). Instead, I found the various PHP file extensions preset in the Text->%content-type.name.() option. This is where I added *.i to associate the old *.i files that I needed to be associated with the PHP Editor. Also, I had to restart Eclipse.
This one worked for me as well. I had to restart Eclipse for changes to take effect.
1

Something extra to be aware of.

I had the same problem, even after installing PDT. Turns out that there was an entry in General=>Content Types=>Text for *.php. Note that this not under General=>Content Types=>Text=>PHP Content Type, which is placed there by PDT. Removing the one under Text fixed the problem for me.

Comments

0

Window > Prefrences > General > Content Types > Text > PHP Content Type add any type of file like *.module, *.install etc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.