Wednesday Jun 11, 2008

How to set up NetBeans to treat files with an extension as PHP files

Sometimes people ask me for an advice, how to set up NetBeans to treat some file with certain extension as PHP file.  For example .phpt files are test files for testing PHP runtime, which contains PHP code and NetBeans Early Access treats these files only as a text files.

There are steps how to do it:

  • Invoke Options dialog (Tools -> Options).
  • In Options dialog press Advance Options button to display Advance Options dialog.
  • Browse  IDE Configuration -> System -> File Types.
  • Expand the File Types node and select PHP Files node.
  • In context menu select Open item, which opens the PHP MimeType resolver in editor.
    Advance Option dialog
  • Close the Advance Options Dialog.
  • Add the <ext> tag to the PHP File MimeType resolver. For the .phpt file is added <ext name="phpt"/> tag. The result file should contain:
  • <MIME-resolver>
        <file>
            <ext name="php"/>
            <ext name="php3"/>
            <ext name="php4"/>
            <ext name="php5"/>              
            <ext name="inc"/>
            <ext name="phpt"/>
            <resolver mime="text/x-php5"/>
        </file>
    </MIME-resolver>
  • Save the change
  • Restart the IDE

I know, this is not so simple as should be, but NetBeans core engineers are working on simplifying the UI. I hope it will be available in NetBeans 6.5 and the specification you can see here.

About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today