I am new to yii framework. On yii version:2.0.1 I have created a module in which I tried to generate a CRUD model using the
After putting the model class, controller class and view path when I clicked on generate gii showed all the files has been created successfully.
But when I tried to view, below message has been shown to me,
The view file does not exist :
I found the view files in web directory not in the path I entered. Hence the error.
Here is my inputs to gii,
Search Model Class:
When I click generate I have given below message :
Generating code using template "C:\xampp\htdocs\advanced\vendor\yiisoft\yii2-gii\generators\crud/default"…
Does anybody have any idea why is it happening.
Thanks in advance.
I solved similar problem by changing
Hopefully it helps someone in future
You missed one final folder and alias in
View Path. It should be
As you can see in creation log, the generated files are in wrong place (root
views folder), that’s why the error is thrown.
Have the same problem. Solved entering @backend/modules/settings/views/companies instead backend\modules\settings\views\companies.
See on slashes.
For view path in CRUD generator, enter the absolute or full path. For example
/home/developer/workspace/advanced/backend/views/<your view folder>
put this in the VIEW PATH
and it’s done!
I have tried with absolute path i,e
It worked for the absolute path.
I tried this is working by entering:
I hope you can do it well.
I’m using the advanced theme
Here is my Gii setup in case it is helpful for anyone
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()
Previously I put a model into the incorrect directory when wanting to achieve an absolute path (address it absolutely as it seems to be more often functional) –
Notice the ‘app’ in the beginning (the /app is the main directory in Yii starter kit) which I thought would avoid the relative path but must NOT be there nor @mail sign, but on the contrary, it did the opposite – it appended it relatively with its absolute length to the /document root directory, basically duplicated it,
So it unwinds from the model location, the causes of Gii complaints about incorrect paths or put also controllers the incorrect way.
Also strangely enough for views in contrast to models, it had to be put the upper mentioned different way with the
@ relative reference sign annotation (which was not allowed to be used for controllers or models at the time of writing)
@backend/modules/settings/views/companies, otherwise it appended the directory tree into the document root, again concatenated – the web directory of backend