Are you sure? If I’m not mistaken it is impossible for Gii to generate a module inside models folder! Gii is generating modules in modules folder and models in models folder, both being a subfolder of protected folder.
I don’t quite understand what do you mean by reguired files and folders? CRUD files? Model? Controller?
But no matter, what you want to achieve the simpliest way to do it, is to prefix your element (model, controller) name with module name and / sign. If you click in a field titled Controller ID in gii, a popup-help will show up saying:
Which means that you should message/Messagemaster, if you want to generate MessagemasterController.php inside message module.
I made a module name ‘message’ using Gii, which is the subfolder of protected folder. Inside messasge module, it has following subfolder generated by Gii : components, controllers, messages, models & views.
Now what I want is: the models [models files] created using Gii should reside inside ‘models’ folder. It’s location is: modules/models/. Ironically it automatically resided inside the protected/model which is not my desire location of the file.
Model Generator of Gii Tool does not allow to generate models somewhere else than in main application. But what seems to be the problem? Just generate model file (always one PHP file) in main application folder (that is protected/models) and then simply move it to your modules/message/models folder? There isn’t even any problem if you already have some model named the same in main application. You generate Model using Gii with different name and then only rename the file and class definition after moving file to modules subfolder.
But the general question is, why you want to do this? Model Generator does not allow generating models in modules because it isn’t necessary to do so. All models should be kept in main application model files, as from there they are accessible by both main application and modules. If you move your model definition to a subfolder, then this model will not be accessible by main application (unless you add additional line to main application configuration file to include it).
To make a better understanding of how it works, try to see module as application-inside-application. You have views and controllers for controlling your main application and you have a separate copy of them to control module itself. Models can be shared in main application models folder, but they can also be put separately to both main application and module’s models folder - it is up to you, what you want to achieve.