Yii 2 gii generates view files in different directories

I am new to yii structure. In yii: 2.0.1, I created a module in which I tried to create a CRUD model using gii functionality .
After placing the model class, the controller class and the viewing path, when I clicked on gii generation, it showed that all the files were created successfully.
But when I tried to browse, a message was shown below to me

View file does not exist:

 C:\xampp\htdocs\advanced\backend\modules\settings\views\companies\index.php 

I found the view files in the web directory in the wrong path that I entered. Hence the error.

Here is my data for gii,

Model Class:

 backend\modules\settings\models\Companies 

Model class search:

 backend\modules\settings\models\CompaniesSearch 

Controller Class:

 backend\modules\settings\controllers\CompaniesController 

View Path:

 backend\modules\settings\views\companies 

When I click the generate button, I gave below message:

Creating code using the template "C: \ xampp \ htdocs \ advanced \ vendor \ yiisoft \ yii2-gii \ generators \ crud / default" ...

generated modules \ settings \ controllers \ CompaniesController.php

generated modules \ settings \ models \ CompaniesSearch.php

generated backend \ modules \ settings \ views \ companies \ _form.php

generated backend \ modules \ settings \ views \ companies \ _search.php

generated backend \ modules \ settings \ views \ companies \ create.php

generated backend \ modules \ settings \ views \ companies \ index.php

generated backend \ modules \ settings \ views \ companies \ update.php

generated backend \ modules \ settings \ views \ company \ view.php

done!

Does anyone know why this is happening.

Thanks in advance.

+5
source share
8 answers

I solved a similar problem by changing

 backend\modules\settings\views\companies 

in

 @backend/modules/settings/views/companies 

Hope this helps someone in the future

+21
source

You missed one last folder and an alias in the View Path . This should be @backend\modules\settings\views \ .

As you can see in the creation log, the generated files are in the wrong place (root views ), so an error occurs.

+2
source

Have the same problem. Solved entry @ backend / modules / settings / views / companies instead of backend \ modules \ settings \ views \ companies. Look at slashes.

+2
source

For the view path in the CRUD generator, enter an absolute or full path. for instance

 /home/developer/workspace/advanced/backend/views/<your view folder> 
+1
source

put it on the VIEWED WAY

@ backend / modules / settings / views / companies

and everything is done!

+1
source

I tried with the absolute path i, e

C: / XAMPP / HTDOCS / advanced / Server / modules / settings / views / companies

He worked for an absolute path.

0
source

I tried this to work by typing: / Applications / XAMPP / HTDOCS / advanced / backend / modules / settings / view / companies

Hope you can do it well.

0
source

I am using an extended theme

Here is my Gii setup in case it is useful to everyone

 module generator ---------------- module class: backend\modules\posts\Module module id: posts model generator --------------- table name: posts model class: Posts namespace: backend\modules\posts\models Enable I18n: checked. category: app CRUD generator -------------- Model class: backend\modules\posts\models\Posts Search model class: backend\modules\posts\models\PostsSearch Controller class: backend\modules\posts\controllers\PostsController View path: @backend/modules/posts/views/posts Enable I18n: checked. category: app Enable pjax: checked If you are using some non-default user management (like amnah module), you need to change Users::className() in the models\Posts.php to \amnah\yii2\user\models\User::className() 
0
source

Source: https://habr.com/ru/post/1210886/


All Articles