Maintaining variants of an application

2019-09-13 03:31发布

问题:

We have a product which is being slightly customized for each client. The exact customization is unpredictable - we assume that any point in the code can become needing change. However, we want to keep one code base, as 90+% of the code will be identical, so we don't have to merge every update or new feature to each client separately.

How can this be done?

The project is written in PHP with the Yii framework.

Basically, we would like something like this: Every client will have a folder with a 'mirror' of the code. That 'mirror' will include only those classes customized for the client. Than, at runtime, the clients identity will be known, and every mention of classes name will be resolved to the generic version of the class - if no client specific version exists for this client, or to the client customized version of that class - if such a version does exist.

I'll appreciate comments about the general design question.
Any comments on the above solution.
Are there other ways to achieve what I want to achieve?
Maybe some code generation tool for generating the client specific version from the current main code?

And also there is the implementation question. How can this be implemented in PHP and Yii?

I thought first to use PHPs __autoload. However, it will anyway choose only one version of the class. And this is a problem, because we'll need to choose the client specific version every time except of one: when defining the client specific version of the class, we will extend the general purpose version of that class. So classes version can not be resolved at the loading time, both need to be loaded, and the client specific will be used every time except of one.

Thank you

回答1:

think svn, cvs, git, all these versioning control system help u to branch, trunk, tag for your code to each clients projects