Let me start by saying for those that found this post and want the quick answer:
- Add “<nature>org.eclipse.php.core.PHPNature</nature>” 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 “<nature>org.eclipse.php.core.PHPNature</nature>” to the <natures> block 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 <buildCommand> elements for us automatically. You’ll also see that a file named “.buildpath” was added to your project directory too.
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?
Hey wagster. You know I haven’t tried moving my PHP files outside the project space. Trying to setup the “PHP Include Path” in eclipse gave me some quirky results in some cases and trying to create a Flex project with a PHP application server type sucks because I can’t get it to work with virtual hosts and only on the http://localhost/. Creating directories under http://localhost for each project is a fix but a pain due to relative path bugs when I push the project to the root web folder of the production server.
I do a lot of Flex project where I’m using PHP/Zend_Amf for the web-services so what I’ll usually do is edit my host file and then setup a virtual host pointing to my “src_php” folder. This way I can have a top level web service URL like http://acme/services.php for my Flex project to query which doesn’t create any relative path bugs when I push it to the production server.
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!
Hey, Thanks for above
If you want to rename your Flex “src” folder and are having trouble let me know and I’ll add how to do that.
Can you post the details about renaming the Flex src ?
Hi Sobers,
If your source folder is named “src”, right click on it and select “Refactor>>Rename”. Rename it to something like “src_flex”. Then right click on your project and go to “Properties>>Flex Build Path” and select the “Source Path” button at the top of that window.
In this example, you would change the “Main source folder” input near the bottom from “src” to “src_flex” or you can browse to select the folder. Hit “OK” and you’re all done.