0

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

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by gidireich
0

In such a situation I'd define my classes/methods for my generic functionality. For every class I'd sub-class it to a client class. The default client sub-class will contain nothing new, and all calls will go through the client class.

class FileAccess {}
class ClientFileAccess extends FileAccess {} // <-- Always use this one, change as needed
0

In such a situation I'd define my classes/methods for my generic functionality. For every class I'd sub-class it to a client class. The default client sub-class will contain nothing new, and all calls will go through the client class.

class FileAccess {}
class ClientFileAccess extends FileAccess {} // <-- Always use this one, change as needed

Thank you, an interesting idea. We're going to have multiple clients, but it can be used combined with __autoload to select the correct client class from current clients directory.

However, currently, it will demand a huge refactoring, as we already have lot of code, and adding the multi-client support now.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.