Manage multiple codebases that share overlapping functions and classes

We have a website on which there are about 9 different code bases for various functions that will be executed on different servers.

We use SVNs and scripts that copy the code from the repo to intermediate servers for testing, so everything is automatic. My problem is that there are functions and classes that exist in different base codes, and they need to be synchronized. Therefore, fixing a small error in a function that receives a time offset will require me to manually edit 5 other files in 5 other base codes. As soon as the code size increases, I don’t even remember that this particular function can also exist in 5 other places.

What would be the best way to deal with this type of thing without creating 2-3 massive "functions.php" files and cloning them to all the code bases each time?

+4
source share
1 answer

I would suggest creating a new SVN repository (which contains common classes, files, etc.) and linking it as an external repository in other project repositories that require common code.

So, for example, you have many projects:

  • Project A
  • project B

etc. etc.

Suppose both of these projects have several classes.

I think one way forward would be to create a new SVN repository that includes shared classes, and then link this SVN repository to your existing repositories.

<strong> Benefits

Allows you to have a single and common code deployed for all projects, without having to manually edit the number of files each time you update the code repository.

Also, I would look at deploying your code using phing (deployment tool) if you are not already doing this. it is really very good and helpful. The link provided is a simple, simple tutorial.

+2
source

All Articles