Yii2 - Gii Creating Crud In A Module

I created a model called "User" and a module called "admin".

When I try to create the CRUD, and enter “admin” as the module ID (as below), I get the error “Module ‘admin’ does not exist.”… but it certainly does. Any thoughts?

Base Controller Class


Module ID


Widget Used in Index Page


Code Template

-default (/home/bootdroid/web/bootdroid.com/yii/vendor/yiisoft/yii2-gii/yii/gii/generators/crud/templates)

you need to include module name in crud fields where it asks where model name



I tried to create another User Model in the admin module, but that seems wrong to me… it also failed in the same way :(

I just want the user-management CRUD to be in the Admin module… but the User model is a sitewide model, and is accessed by a standard User Controller as well, for regular end-user functions…

Does that make sense?

Keep the User model in site models and generate crud controller as


by setting model path as


You need to first setup/add the module in the modules section of your application Yii Config file before running gii.

Something like:

'modules' => [

    'admin' => [

        'class' => '\app\modules\admin\Module'



DOH! You are totally right! Nice call… thanks very much :)