Yii Multi-Site: One Common Core, Extend Everything For Sub-Applications


I’m about to program a multi-site YII application that can be used to organise business running events (company and runner registration, invoicing, creating teams etc.).

I want to have a common core (Models, Controllers, Views etc.) with basic functionality but be able to extend every class or part of the application if needed.

In the final setup, I want to setup several applications for different running event organisers and eg. if one running event organiser wants custom pricing that can’t be handled via the basic core functionality, I’d like to extend the responsible class…

What’s the best way to do this?

I read http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site/ which sounds interesting.

Furthermore I though of using an own autoloader, editing YiiBase::classMap or CWebApplication->controllerMap but all in all I’m a bit overwhelmed ;)

How I’d want it to be: basic functionality should work out of the box, if I want to extend a model or a controller, it would be cool to somehow do this without changing the model/controller name to not have to rewrite the occurences of the base-controller everywhere.

What about having the basic functionality in the common/ directory (see link above) and in the frontend-event1/ directory extend EVERY model/controller etc., but only add properties or methods if needed?

I hope it’s clear what I’m trying to achive. :)

Thank you very much.


thanks for your reply!

I forgot to mention that I already have had a look at YiiBoilterplate, look interesting too!

My question is how to concrete implement the ability to extend the common classes?

An approch would be to prefix all common classes (like Yii does by adding "C"), eg. CRunner or CCompany and then in the frontend/ directory extend all these classes and name them Runner respectively Company and only extend functionality if needed.

What do you think about that? And is there an approch without having to create the Runner or Company class in frontend/ if I do not want to extend anything in a specific project/application?


It sounds to me that what you want to do is possible just using modules. I don’t see the need for the application to be complex enough that you would need to modify the Yii classes.

You could have the "basic" functionality in a configuration table for the application, or for each module, however you prefer. This configuration would load (for example, when creating a new event) and prepopulate some model fields, but the user creating it can just modify them according to their needs and a new event would be inserted.

Each module would be a different "app" in your site.

-Core application

–Events Module

—Some event submodule


—Invoicing submodule

You get the idea.