Yii Framework Forum: How to create new Module using gii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

How to create new Module using gii cann't create model,Controller,CRUD and form new module using gii Rate Topic: -----

#1 User is offline   Veera(Yes it is) 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-January 11
  • Location:Coimbatore,India

Posted 26 January 2011 - 03:50 PM

Hi,

I would like to create a new module using gii.
The new module is successfully created.

I tried to create new model,Controller,form inside the module
but it always creates these files in not a corresponding module

Attached File  yii.jpg (104.7K)
Number of downloads: 382

Here in this sample,

help to create model,Controller,form inside the email module using gii...?
0

#2 User is offline   twisted1919 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 634
  • Joined: 23-October 10
  • Location:Romania

Posted 26 January 2011 - 04:31 PM

Let's say you have a module named admin, and you want to create a new controller that goes into the admin module and it's name is users.
in this case, when you generate a new controller, in the Controller ID * field, you will pass admin/user so you will have MODULE_NAME/CONTROLLER_NAME instead of having just CONTROLLER_NAME.
Same things for CRUD or models.
1

#3 User is offline   Coda 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 101
  • Joined: 20-September 10
  • Location:Kathmandu, Nepal

Posted 26 January 2011 - 05:04 PM

To create model inside module['email'], you can edit the text-box during creating model. And you need to change the location. By default every models, are created inside models.
For this, in the Model Path you need to edit with : application.modules.email.model
Now your model is created inside email/modules/model/


View PostVeera(Yes it is), on 26 January 2011 - 03:50 PM, said:

Hi,

I would like to create a new module using gii.
The new module is successfully created.

I tried to create new model,Controller,form inside the module
but it always creates these files in not a corresponding module

Attachment yii.jpg

Here in this sample,

help to create model,Controller,form inside the email module using gii...?

1

#4 User is offline   brainless 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-January 11

Posted 27 January 2011 - 08:54 AM

View PostVeera(Yes it is), on 26 January 2011 - 03:50 PM, said:

Hi,

I would like to create a new module using gii.
The new module is successfully created.

I tried to create new model,Controller,form inside the module
but it always creates these files in not a corresponding module

Attachment yii.jpg

Here in this sample,

help to create model,Controller,form inside the email module using gii...?


hi veera,

i have read your post. i think you are not familiar with concepts of yii completely yet. i could suggest a book to go through the concepts of yii and MVC pattern.

Link to yii book said:

here is the link to the book's information: goo.gl/yLX3h
I am interesting to know about you progress with yii framework. all the best. enjoyii.
1

#5 User is offline   lifeLogic 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 22-March 12

Posted 26 March 2012 - 06:01 AM

Hi Veera,

I just ran into the same problem you had when trying to use gii or yiic shell to create a controller for
a module. The above posts give accurate help but missed one step.
You must set your yii web application configuration file to include the module your are building.
I believe this is the problem you are having.


For example, I built a module called "users". Then, I wanted to build a controller for that module.
Before building the controller I first went to the application configuration file:
/webserver_directory/project_name/protected/config/main.php
Then, in that file I found the modules section and added the new module name "users" to it:
'modules'=>array(
// uncomment the following to enable the Gii tool

'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'*****',
// If removed, Gii defaults to localhost only.
'ipFilters'=>array('127.0.0.1','::1'),
),
// Must have or shell command will not put files in module.
'users'=>array(),

),

Notice, the module section of your config file is also where your gii configuation is.
You need to add the 'users'=>array(), to the modules=>array. After making this change,
you can use yiic shell or gii to create a controller for the module and it will place
the controller and view files in the module. If you skip this step the controller and view files made
by gii or yiic shell will be placed in the regular controller and view folder instead of the
module's controller and view folders.

Code to make a module controller in yiic shell.
module users/users login logout listUsers manageUser

I hope this helps.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users