Eclipse PDT: Creating project at existing location (from existing source) doesn't work

You probably need to move code in an existing folder to Eclipse. This is the work around for starting to work with existing php code in Eclipse PDT in Windows 7. Don't follow these steps if you have your code in a VCS; there are other steps for dealing with that scenario, and those steps are not covered here.

Moving existing source code into a new project in Eclipse

1. Set the workspace one directory above where your existing code lives.
2. Create a new PHP project via File->New->PHP project
3. Create a new project with a different name from your current folder. Make sure to select Create new project in workspace under Contents. Don't pick Create project from existing location. It doesn't work
4. Once your project is created, go to File->Import. Select General-> File System.
5. At the From directory field, pick the folder where your current code exists. Then click Select All. Click on Finish

The long story

I want to like eclipse. I really do. I like the idea of it. I like it how it is open source and how anyone can create a new distribution for different languages.

Yet Eclipse makes it so hard to be loved. It turns what should be a thoughtless task into a research project.

At least I believe that setting up a new project and importing existing files into it should be easy. And when UIs don't actually work as they claim they should, the experience of using eclipse is a mixture of confusion and frustration.

So look at this UI for creating a new project. The UI is clearly telling the user that one should be able to create a project from existing source files. Excellent! That is what I want!

Photobucket

However, when you try it, it won't work. It will give you an error that says, " Cannot create project." Below is a warning that says, "The specified external location already exists".

Why doesn't it work? Search the internet, and maybe you will be looking to find this page:

http://www.myeclipseide.com/PNphpBB2-printview-t-10438-start-0.html

Where several people describe how the UI does work in linux for java, or that it is only meant for folders under the web server root. It is unclear what is going on. The bottom line is that it just doesn't work. It wasn't working in 2006, and it isn't working now. The thread has several workarounds, but the only one that worked with the current version is the one that I shared at the beginning of this entry.