So to my surprise recently, Eclipse PHP PDT doesn’t show syntax highlighting for files which don’t have the .php (or variant of that) extension. i.e. it won’t allow a blank extension.
Honestly there is no reason not to use the .php extension if you’re working with a proper MVC framework, however in some recent work i have come across i’ve seen this used to facilitate “pretty” urls, which in turn has a positive influence on SEO ranking of course.
So, the solution is as follows. Once you have your eclipse plugins for PDT installed you need to locate the following 2 jar files and unzip them (use 7zip or winrar for this):
- org.eclipse.php.ui_1.0.3.v20080603.jar
- org.eclipse.php.core_1.0.3.v20080603.jar
Once you have unzipped them you need to have a look inside the folder and locate the plugin.xml (should be in the root of the unzipped file). Inside there you’re looking for the corresponding lines:
- file-extensions=”php,php3,php4,php5,phtml,inc”
- <site extension=”php“
In both the above lines you need to alter the part inside the inverted commas (”"). All you need to do is add a comma (,). i.e. changes the lines to the following:
- file-extensions=”php,,php3,php4,php5,phtml,inc”
- <site extension=”php,”
All this does is tell the syntax interpreter that the PHP highlighter will be responsible for the blank ( ) extension, i.e. no extension.
I have previously tried utilising the * syntax to get it to work for all files, however the issue with this was that it seemed to break the debugger (XDebug).
One other thing to note is that you need to set the path mapping parts of your server correctly. ESPECIALLY if you’re using some form of external network drive. The usual setup is to have the path on the server (e.g. “/home/httpd/vhosts/sandbox”) and map it to the project base in eclipse, however you should also add in the mapped network drive path as well (as the project path).
ET VOILA! Non existant file extensions will now work with PHP Eclipse.
nb: I suspect this will break eclipse for any other file types that don’t have extensions and cause them to be read in the PHP editor. I also have a sneaking suspicion it may be causing a problem with CVS in PDT thinking that images are ascii format and not binary.