How to upgrade end-user-modified code

Hey guys, I have a really tricky situation here: I’m developing a Yii web app (www.x2engine.com), and it’s downloaded and installed on servers all over the world. Many of our customers want custom features, which are quite easy to implement, but become a major issue when we run an automatic update. Our updater basically generates a list of files to update to bring the installation up to date, then downloads and replaces those files.

So, either their custom code is overwritten, or they don’t get updates. Because of the complexity of this software, it is quite unlikely that just skipping modified files would produce a stable application.

The best solution we’ve thought of so far is to create empty child classes for any file that gets modified (such as a controller), so it extends the real controller. Any modifications would go in the child class, which would then be left alone by the updater. And this way, all the code within that file could be updated, except the custom overridden methods.

What I’m asking is this: how can I tell Yii to look in a folder for one of these extended classes, and use it instead of the real one if it’s there? We don’t want to create an empty child class for every single file (we have hundreds of classes, this would be silly).

This idea would only apply to classes; views can’t be extended, but I think we’ve got a good solution involving themes, since themes already do this exact same substitution for views.

Thanks for your help!

Code is modified = warranty void, thus no updates.

Srsly.

PS. For using extended classes you can modify router rules.

Take a look:

http://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-custom-url-rule-classes

Normally I would agree, but our business model is focused on hosting, support, or both (which sometimes includes customizations), so its often going to be us making the modifications. It’s just way too much work to reapply them every time we update their installation.

Thanks, this looks promising. I was afraid the URL manager wasn’t powerful enough for this but this class is a good lead. Might be able to have it search for customized controllers with different names (like MySiteController vs SiteController), and redirect to that route if it finds the file.