0

I have a number of projects in Eclipse PDT which are all websites. All of these websites use a content management system that I developed. I moved the code for the CMS into a separate project ready to be shared.

So far I have a project/file structure similar to this:

CMS [CMS master]
  -CMSlib
Website1
  -scripts
    -CMSlib
Website2
  -scripts
    -CMSlib

The CMS\CMSlib folder contains the shared code and the CMS project itself is connected with a local Git repository and represents the latest version. I'm not sure how I should share this code between projects. If I am to share this code I must be able to retain the following workflow functionality:

  • I must be able to test the websites on a web server. I have WAMP installed for this purpose. Adding the CMS project to each website project's include path in Eclipse is no good as a web server has no knowledge of eclipse. So I need the files to be present locally (ideally within the scripts\CMSlib folder within each website project).
  • The code for the CMS must be easy to update for all websites. So if I add a feature to the CMS project it should be easy to update the CMS code for each website project.

So what is the best practice when these requirements are needed? Is there some way of pulling files from the repository into other projects with EGit (I am a Git beginner by the way)? Or am I missing some other setting that allows this to be done using the include path?

Note: Copying and pasting CMS\CMSlib into a website project's scripts folder comes up with an option box forcing me to skip the operation if the folder scripts\CMSlib already exists.

Jonathan
  • 1,256
  • 4
  • 12
  • 18

1 Answers1

1

Since you are using Git, you can use the "Submodule" feature: http://git-scm.com/book/en/Git-Tools-Submodules.

With the Submodule feature, you can keep all of your websites under a single project directory; however, if you want each website to use different versions of the common code (which is pulled in as a submodule), you just need to submodule the common project into each website individually.

You could also do this without submodules. You can simply "require" (or autoload) the common code from each website. Every IDE that I've ever seen used allows you to pull in extra libraries or packages. I don't use PDT; however, I'm sure it's there.

EDIT: Actually, a quick google produced: "Configuring a Project's PHP Include Path".

Wil Moore III
  • 6,968
  • 3
  • 36
  • 49
  • Am I correct in thinking that in order to use this feature I would have to version control each website project and then add a submodule inside each one which links to the CMS repository? If so, the only problem is that it would be preferable not to have to version control each website. Would it mean that every time a change is committed in the CMS project it will automatically update all submodules linked to it? – Jonathan May 21 '12 at 15:06
  • I already addressed the include path issue in the first bullet point in my question. The issue with simply requiring the code is that each website project represents the hosting's public_html/www directory. So the code needs to be somewhere within that directory to be tested locally (and accurately) with WAMP and ftp'd easily. I think I'll test the submodules feature for a bit. Failing that I'll revise the project structure. – Jonathan May 21 '12 at 17:52
  • Fair enough...I hope it goes well :) – Wil Moore III May 21 '12 at 19:15