Zend Studio for Eclipse – No file extension as PHP
I've been a Zend Studio user for a long, long time. Being a Mac user has made it interesting at times (we're still a server release behind, for example), but the productivity gains that using an IDE with a debugger gives me makes the occasional “suck” well worth it. There are others out there, but this is the best one I've found for PHP.
A while ago, Zend turned to the Eclipse project for their IDE. Eclipse is an open source cross-platform Integrated Development Environment that supports many programming languages. It provides syntax highlighting and lots of other goodness way beyond the scope of this post. If that stuff geeks out out, look here: Eclipse.
I'm thinking that Zend made this move to allow them to focus on the core Zend Platform instead of working on a custom IDE for the whole thing. It makes perfect sense really, and it makes sense that there would be a few bumps in the road as the product matures.
On of our products uses a feature of the Apache server that allows you to process specific files with a particular plugin. In our case, we wanted the “page” script to be processed as a PHP file. The “page” script has no file extension… it works well, and has for a long time. Zend Studio 5 has always allowed us to edit the “page” script, including PHP syntax highlighting and debugging, with no problems. It turns out that Eclipse doesn't pay attention to the content of the file, but instead uses the extension to decide how to treat the file. Bummer.
Again, Zend Studio 5 is a proprietary IDE made by Zend, and Eclipse is an open-source application, with a whole new architecture to support. Things happen, right? Well no, this was too much of a problem for us, so we've put off moving to Zend Studio for Eclipse until support for no extensions is added.
I sent a tweet: “Zend Studio 6.1 still doesn't let me associate a file with no extension to PHP. Guess we're sticking with 5.5.1 for now.” and a little bit later was replied to by royganor from Zend. He mentioned a trick to make it work.
What a trick, indeed. Do this at your own risk. If you bork your install, I'll try to help, but ultimately you're on your own.
1. Go to your Zend > Zend Studio for Exclipse 6.x > Plugins folder and look for org.eclipse.php.core. Mine was actually a .jar file. If it is a jar file, simply rename the .jar to .zip and decompress. The resulting directory will work the same as the .jar file. (keep the .zip as a backup)
2. Search for the string: file-extensions
3. Add a comma inside the extension list. Mine looks like this: file-extensions=”php,php3,php4,php5,,phtml,inc”
4. Save the file and start Zend Studio for Eclipse
It turns out that the double comma is interpreted as an empty string, as it should be. But this is dirty, yep. Expect it to be overwritten by your next install, etc. But all files that don't have an extension will now be handled as PHP by Eclipse.
UPDATE for Zend 7.2: Apparently the custom user extensions have been moved to the folder in your home directory. I found it through trial and error here: ~/Zend/workspaces/DefaultWorkspace7/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.runtime.prefs The same rule applies… just add an extra comma to the content-types/org.eclipse.php.core.phpsource/file-extensions value, then launch Zend Studio with the -clean option. I've tested it, and it works. Thanks again to royganor for the inspiration.