Best practice for creating models & modules

Hi,

I’m new to Yii and I want to create quite a large application that i would like to divide over 5 modules. These modules are carefully chosen based upon the specific task they need to do. These 5 modules will all work on (parts of) the same business logic which are essentially a bunch of models. So my question is, where would be the best practice location to create these business logic models? Should i create them under \app\models or would it be wiser to create another module containing just models?

In my own opinion i would create them under \app\models because a module is more like a small application that can run on its own and requires controllers and such and i don’t need any of that for these models.

Could be that i just answered my own question, but i’m just looking for a 2nd opinion then :)

tia

-fluxlicious

In one of my projects I have created "common" directory under @app directory.

It’s not a module, but just a directory that has “models” and “utils” sub directories where I store common models and utility classes for the whole project.

The project is based on the "basic project template", but I introduced the idea of "common" directory of the "advanced project template".

The following line is added in @app/config/web.php.




Yii::setAlias('@common', dirname(__DIR__) . '/common');



Now I can use any of my common models using a syntax like "common/models/MyModel".

I don’t say that using “@app/models” directory is a bad idea. It’s OK. But you may want to organize your common models under a dedicated directory.

Thanks for the idea, this would indeed be the best solution.