Using Gii to generate code inside a module

I want to generate a controller, model, etc inside a module, how can i do this? it seems I can only generate those if I choose to not use a module, or would I have to generate the files and then copy them into the module folder?

Well… Im sure in the gii form there is a field that askes you for the path to put the file, which by default i think its application, so just change that to: application.modules.yourmodule.controllers etc.

If you want to create controller, then in the controller ID instead just typing the controller name you add module name like this:

mymodule/mycontroller

doesn’t work, I have a few I want to do, I tried the user module

user/user - did not create in the module folder when in the system controller folder and created controllers->user->UserController

modules/user - CException

Alias "modules.ModulesModule" is invalid. Make sure it points to an existing PHP file.

Looks like this is not possible

I’m not sure if its save to generate them and then move them into the module folder?

Well, you need to create the module first at the Module Generator.

After module is created, then you can create the controller into the module by giving "moduleName/controllerName" at the Controller Generator

I found what the problem was, the module wasn’t activated properly, after I fixed that, I did user/user and the preview showed the correct paths.

When I have time I should put together some screens form generating the controllers/models/crud from modules i’m sure others will be as confused as me.

Thanks for the help guys

  1. Create module

  2. ENABLE the module in main.php

  3. Then, create the crud etc for the module,

(path will then work in the "Controller ID" as eg admin/users)