Yii 1.1: Easy way to create a Module in Yii

on

Creating a module in Yii framework is very easy.

Any one can see bellow link:

http://www.yiiframework.com/doc/guide/1.1/en/basics.module

Here I will describe how any one can create a module very easily in Yii.

Yii have a code generator that is called gii.

1. If we have several database table, then 1st we need to generate model and CRUD from GII.
 model  Crud
2. All model and CRUD files will now in protected folder (controllers/models/views).
 protected
3. Now we will generate a basic module from GII. If i create a module named category, then in modules folder, there will be a folder name category. And only highlighted folder/files will create.
   module  defult_module
4. Now cut files from protected folders (controllers/models/views), to the new modules folders. Like in the upper picture, black crossed files, corresponding controller are now in module controller folder and so is others (models/views).
5. For view the pages, URL will be same, just need to add the module name in-font of the all URL.
6. And of-course we have to add module name in main config file:

‘modules’=>array(
‘category’,………..

)

Leave a Reply

Your email address will not be published. Required fields are marked *