[Eclipse] How to configure PHP code recognition and coloring in files with extensions like html

Tadashi Shigeoka ·  Fri, March 16, 2012

I researched how to configure Eclipse 3.7 to recognize PHP code in files with extensions like html and enable syntax coloring, so here’s a memo of the steps.

■ What I want to do

・Make it possible to open with PHP editor

・Enable syntax coloring

Steps to configure Eclipse to display *.html files with PHP editor syntax coloring

  1. Go to Window → Preferences → General → Editors → File Associations

  2. Click “Add” in “File Types”, enter the file extension you want to add, and click “OK”.  ・This time enter “*.html”

  3. Select the added item (*.html) from “File Types”, then click “Add” in “Associated Editors”.

  4. In “Choose the editor”, select “Internal editors”, choose the editor you want to use for this file type, and click “OK”.  ・This time select “PHP Editor”

  5. Go to Window → Preferences → General → Content Types

  6. In Content Types → Text → PHP Content Type, click “Add” in “File associations”.

  7. In “Content Type”, enter what you entered in step 2 (*.html) and click “OK”.

  8. Finally, restart Eclipse.

Now you can open files with *.html extension in the PHP editor with syntax coloring enabled.


Reference Information

Eclipse上でhtmlファイル内のPHPのコードを認識させる方法 - Coding Edge会議室

Eclipseエディタの色設定 - 役立たずのプログラマーブログ

That’s all from the Gemba.