Let me start by saying for those that found this post and want the quick answer:
- Add “
org.eclipse.php.core.PHPNature ” to the “.project” file. - Refresh your project in Eclipse and you’re done (Eclipse will add the remaining needed files and elements to your .project file automatically).
For those of you that want it in detailed version and some extra tips, read on….
It’s pretty easy to add an Adobe Flex project nature to an existing PHP project in Eclipse as you can see below (right click on your PHP Project)
… but going the other way around and adding a PHP nature to a Flex Project can be a little more tedious but not all that bad. I’ll be using Eclipse 3.4 with the Flex 3 Plugin and PDT 2.0 for this example. It won’t matter if you’re on Mac or Windows. Here’s how to do it:
- I’ll start from scratch by creating a Flex 3 project in Eclipse named “My Flex Project”.
- Next, locate your “.project” file and open it
- Now in the .project file you’ll need to add “
org.eclipse.php.core.PHPNature ” to theblock shown circled in red below and then save it.
- In Eclipse, right-click on the project and select “Refresh”. You’re done!
Now if you go back and look at the .project file we edited in step 3 above, you’ll see that Eclipse added extra
One thing I recommend is creating a separate source folder in your project to organize your PHP code and keep it isolated from your Flex code. To do this:
- In Eclipse, create a folder in the root of your project. I’ll name the folder “src_php” for this example.
- Right click on your project and select “properties”. Go to “PHP Build Path” and remove the default build:
- Keep that window open and click “Add Folder”. Check the new folder you created for your PHP source (“src_php” in this example) and click “OK”.
- Click “OK” in the “PHP Build Path” window and you’re finished!
The good thing about doing this is that your folders like “html-template” won’t be taken for PHP packages. If you switch between the Flex and PHP persepective you’ll also notice that the associated source folder always positions itself at the top of the directory structure (not a big deal but it’s nice).
NOTE: If you want to rename your Flex “src” folder and are having trouble let me know and I’ll add how to do that. It takes a small tweak in the .actionSriptProperties file after you rename/refactor the src folder. You’ll also have to reset the default mxml application file.
Thanks for that, project natures can be a bit tricky in eclipse.
I’m using a setup much like yours – Eclipse + PDT plug-in + Flex Builder 3 plug-in – I don’t use Flex really, just AS3.0. I’m also using xampp. At the moment I have my server root set to my workspace root – mainly because I thought that all files should live in the workspace. Have you tried keeping the PHP files in a separate server root and leaving the .as files in the workspace? Can eclipse cope properly with files not in the workspace?
Great, I’ll look into the virtual host trick. If it works as well as the .project tip did, I’ll be a happy camper!