How can I associate a file extension with a content type?

Solution 1:

There is not a safe and advisable way to achieve what you are after because this function of the OS is controlled by the Launch Services database. Developers register the filetypes their applications support with the OS on first launch.

The best way to get this fixed is to petition the developer to add support for the file extension in a future version of their application.

With that said you have already found the only documented way that Apple offers for overriding the edicts of the Launch Services database. If you want to dig deeper and take the road less traveled supported here are a few pointers.

There is a .plist file that governs part of what Launch Services does located at: ~/Library/Preferences/com.apple.LaunchServices.plist

Apple notes that removing this plist can clear out unwanted Open With contextual menu options. But that's the opposite of what you're after.

It's a binary .plist but you could convert it to an xml version and experiment a little to see if you can come up with a recipe to achieve what you're after. This isn't advisable, it could cause harm, and it will most likely get overwritten by the OS at some point.

There is also a tool hidden a bit deeper in the OS called lsregister which could be helpful in exploring Launch Services's plumbing. Here is a helpful explanation of lsregister and its options.

Solution 2:

The Alternative to the Solution mentioned by Gerry is the RCDefaultApp Preference Pane. It's free and let's you set all Application->Content Type, Application->URL connection on your System.

In the "Apps" Pane of RCDefaultApp you can set what file Types a specific Applications Supports when you check "php" with your Editor it will also show in the "Open With" Menu.