Managing version synchronization across multiple instance using a single code source

I have a code set which I would like to use on multiple websites. The code set defines a platform which will be used on multiple subjects. I want to force each website instance to automatically synchronize with this source so they always remain on the same version of code. It gets a little tricky become some website instances will not be a full version of the source code.

For example:
The source code consists of:
component A
component B
component C
component D
component E

Website Instance 1 consists of:
component A
component B
component C
component D
component E

Website instance 2 consists of just:
component A
component D
component E

Website instance 3 consists of just:
component A
component B
component C

Each instance may not have the same arrangement of components as the other, but the common goal is to retrieve the necessary components from the source code when an update occurs. My current approach involves running an update script which knows the configuration/make-up of each individual instance. It then replaces the entire website instance code with a copy of the newly updated code from the source. This works, but it seems to be messy an error prone. Is there a better approach for managing version synchronization across multiple instance using a single code source?

Thanks.

Any input would be appreciated, even if it just to research a term or technique. Not sure where to start here. Thanks.

Are all these on the same server?

All the websites are on one server. The source code is currently on a different development server. However, the source code could be stored on the same server as the websites without much difficulty.

OK, what about the components? Are they exactly the same for each of the sites?

Each component has the same source code. The only difference between implementation is contained within a config file. The config file contains all of the dynamic data, this includes meta information, email address, site name, database connection (each instance of each component has its own database).

Website 1 Component A will equal Website 2 Component B minus the differences defined in the config file for Component A. However, Website 1 is not required to have Component A, it may only have Components B and C.

I hope this makes sense. If not let me know and I’ll try to explain it better.

Great.

What about symlinks then?


www/
  /lib/
    /core/
    /components/
      /a/
      /b/
      /c/
  /site-a/
    /www/
    /lib/
      /core/<-- Symlink to /www/lib/core/
      /components/
        /a/ <-- Symlink to /www/lib/components/a/
  /site-b/
    /www/
    /lib/
      /core/<-- Symlink to /www/lib/core/
      /components/
        /a/ <-- Symlink to /www/lib/components/a/
        /c/ <-- Symlink to /www/lib/components/c/
  /site-c/
    /www/
    /lib/
      /core/<-- Symlink to /www/lib/core/
      /components/
        /b/ <-- Symlink to /www/lib/components/b/

All the actual files are located in /www/lib/ and the other sites mearly use a symlink to the required core and components. Adding a new component is as simple as adding a new symlink to the source folder.

This way, you can update everything in /www/lib and every folder linking to it will automatically receive the new source.

Interesting idea, how would I manage unique configs through this system.

Website 1 has a global config.
Website 1 - Component A has a config
Website 1 - Component B has a config

Website 2 has a global config.
Website 2 - Component A has a config
Webiste 2 - Component D has a config.

As I understand symlnk usage (which is not very well), it would enforce the use of whatever config is located in the source directory.

I would probably add component config to the global config for simplicity, unless you need to keep this separate?

If

/site-a/
/www/
/lib/
config.file
/core/<– Symlink to /www/lib/core/
/site-b/
/www/
/lib/
config.file
/core/<!-- Symlink to /www/lib/core/

In this example, will config.file interact with the contents of /www/lib/core/ the same way it would interact if it was directly in the /www/lib/core/ directory?

Lets say the contents of /www/lib/core/ is

config.file
index.php
about.php
contact/
contact.php

If I remove config.file from this location entirely and require /site-a/ and /site-b/ to contain the config file as seen in the first quote. Would this work? If not, any suggestions on how to get this idea to work?

I’m trying to understand how this works.

Well, the behaviour side of things depends on your code. Initially, I’d look at a site structure similar to:-


  /site-a/
    /www/
      index.php
      contact.php
      store.php
    /lib/
      config.file
      /core/
      /components/
        /a/

Where ‘core’ and ‘a’ are symlink’d.