Eclipse: Changing Project Type

I’ve just added a new project from an existing location in Eclipse Juno, and for some reason it wouldn’t let me create it as a PHP project. Instead, I had to just create it as a general project. Having done this, it is fairly easy to convert it to a PHP Project, by doing the following:

  1. Open the .project file for the new (non-PHP) project in a text editor
  2. Open a .project file for an existing PHP project (or, if you haven’t got an existing PHP project, create one in your workspace and use the .project file from that)
  3. Copy the <buildSpec> and <natures> sections from the PHP .project file (from 2. above) to the .project file for the project that you want to change to a PHP project (from 1. above)
  4. Save the new modified .project file and refresh the workspace
  5. The general project should now be a PHP project

The .project file for my PHP projects looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
   <name>project_name</name>
   <comment></comment>
   <projects>
   </projects>
   <buildSpec>
      <buildCommand>
         <name>org.eclipse.wst.validation.validationbuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>org.eclipse.dltk.core.scriptbuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
   </buildSpec>
   <natures>
      <nature>org.eclipse.php.core.PHPNature</nature>
   </natures>
</projectDescription>

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.