An Oracle blog about NetBeans for PHP

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>
  • 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.

Join the discussion

Comments ( 3 )
  • Lee Ethridge Saturday, November 8, 2008

    A comment in that file says "when modifying this list also update the PHPIndexer.INDEXABLE_EXTENSIONS". Where would we find this file?

  • Petr Monday, November 10, 2008

    Hi Lee,

    where do you see the message? It's a developer comment and it shouldn't be visible anywhere in the ui.



  • guest Tuesday, May 12, 2009


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.