Need advice about application modules.

I'm in the need of advice with this:

I have an app in Prado 2, with several modules. Each module contains the views (tpl), "controllers" (php pages) and model (php module file) of one logical unit of the system (let's say, a Blog, or a Chat).

How can be this mimicked with Yii? I was thinking on using controllerMap, but as I understand the Yii controller is the equivalent to the page in P2…

Thanks in advance…

Actually controller in Yii is equivalent to a collection of pages in Prado.

Usually, a controller is responsible for CRUD operations of a database table. So it is more like the module concept in Prado.

You do not have to put all controller action logic in the single controller class file. Instead, you can create individual controller action classes to accomplish CRUD operations.

As a result, depending on how many database tables you will be managing, your system will be end up with several to dozens of controller classes together with their action classes organized in subdirectories.

Thanks Qiang. Ok, then if in P2 I had:

[tt]

modules/Module1/Page1

modules/ModuleN/PageM

[/tt]

now in Yii I'll have:

[tt]

controllers/Controller1.php

controllers/Controller1/Action11.php

controllers/Controller1/Action1N.php

controllers/ControllerN.php

controllers/ControllerN/ActionN1.php

controllers/ControllerN/ActionNM.php

[/tt]

right?

Now another question: what if I had master-detail tables, and I had one page for master, one (or multiple) page for detail, and the associated new/edit page(s)? Do I need to have one controller for the master and one for the detail, with the associated action classes?

Thanks for answering these (rather basic) questions :slight_smile:

Yes, that's the directory structure I would recommend, but it really depends on your personal taste.

For master-detail tables, I'm not sure what is the best organization. Maybe you can try and share your thoughts here?

Quote

Yes, that's the directory structure I would recommend, but it really depends on your personal taste.

Indeed. I would prefer to have something like:

[tt]protected/controllers/Module1/Controller1.php

protected/controllers/Module1/Controller1/Action1.php[/tt]

because I feel this would give me a cleaner controllers directory. Is this possible to do with Yii?

Quote

For master-detail tables, I'm not sure what is the best organization. Maybe you can try and share your thoughts here?

Sure.

This is possible, but you have to override CWebApplication::createController and extend CController. Actually, once you try, you will see this is bringing more trouble than convenience.

Another way was discussed here.

You can create a protected dir for each module and configure controllerMap and controllerPath.

Quote

Another way was discussed here.

Thanks for the hint Khaoz, that's exactly my problem too. Follow-ups on that thread.