Yii: Overall design approach and layout of large project

I am currently working with a rather large db (amount of tables). This db can easily be divided or segmented for the associated functionality of the data that in stored within the entities. For example…address, party (user or business), categories, products, and so on.

My question is how should I layout Yii to interact with this? Originally I created a module for each of those groups (address, party, categories, products, and so on) but now I am wondering if I am using a module in the wrong manner.

Should I keep all my models together under the main app and then create modules that tie in the functionality for different things. Such as listing products with my current approach I would be utilizing party (business), categories, products, and maybe even address modules. Now I am thinking this should all be one module pulling from the main app models, but then I would have duplicating models. One under the main app and another in the module.

Can someone pull me out of this web of confusion and set me on the right path? This confusion is clear in my head but not sure my question is easy to understand. This of course is a design and methodology question and not one about coding.

Hi enfield,

Ahhh, another in search for the Holy Grail :)

I think it depends on your application and its needs, also an imporant part is the versioning system you use, which can help you with copies of the same module or functionality.

You may take a look at http://www.yiiframework.com/forum/index.php?/topic/17591-planning-yii-cms-a-different-approach/ which is a (long) thread about a related topic, also about module conventions.

Best regards,


Hey schmunk,

Thanks for the link and taking the time to write all that up. Glad to see I am not alone with my thoughts. Just been through a bit of it so far and glanced over other parts but this is the type of info I have been looking for. Although the letters CMS make me really hesitant your approach seems interesting and I am sure I can learn something about overall structure to apply to my current project. Back to reading.


I know, most Yii Developers are hesitant when it comes to the letters “CMS”. :unsure:

But the linked thread above is more about application setup and conventions. The CMS part is currently just a module.

In case you haven’t seen it, this might also be interesting:


I think people tend to go wild using modules…

I don’t know why - most probably because programmers tend to complicate the heck out of everything. :lol:

Design your application through your database schema and generate the overall skeleton using Gii/Giix.

Then you should have something to flesh out your application with.

If something looks/feels wrong, maybe you need to tweak your database schema?

Only if you find yourself re-implementing something in several applications, it makes sense to move that out into a module.

A module is only a mini-application in your application, remember?

If you want to create a killer CMS framework with dynamically attached/detached modules, then take a good look at what Schmunk is doing - otherwise: don’t bother. ;)

I my app I am doing now, I have three modules: admin module, user module and Rights module.

Only the admin module is made by me, the rest are from the Yii extension page.

I’ve been wondering if I should just move the user module into the application because there’s no real reason for having it as a module… It’s customized beyond recognition with app-specific code anyway… ;)

However, I will soon need wiki functionality for several of my apps, which is why I am going to write a wiki module soon.

IMO, implementing your business logic using modules with app-specific code is just over-complicating stuff…

We are already using the MVC framework, remember?

Models, Views, Controllers…

I tend to use Widgets and Components to DRY.

Modules are totally overkill (not the right tool), in my humble opinion.

The main point, since we’re using a modern MVC web framework here, is that you design your application primarily by means of designing your database schema.

If we were using Symphony or RoR, then we just generate our application from it, and that’s pretty much it.