Yii2 Page not found when calling country/index

怎甘沉沦 提交于 2019-12-12 03:26:16

问题


I was practicing to work with Yii2 based on the tutorial in this link : http://www.yiiframework.com/doc-2.0/guide-start-databases.html

I am using Advanced Application These are the files that i have created:

frontend/models/Country.php

frontend/controllers/CountryController.php

frontend/views/country/index.php

now when i try to access it using index.php?r=country/index i get 404 not found error. But if i move the actionIndex of CountryController to SiteCountroller and rename it to actionCountry and also move my view file inside site folder (and of course change the name of index.php to country.php) then i can successfully see the list of countries using the address index.php?r=site/country

Any ideas about the 404 not found error?


回答1:


Examples in tutorial are for basic application and contains app\ in namespaces declaration. And you are using advanced application so for frontend it should begin with frontend\ (see for example SiteController in advanced application).

I think this is the reason since you said that file content is exactly the same, you didn't change default configuration and checked folders, files and classes for correct names.



来源:https://stackoverflow.com/questions/28344052/yii2-page-not-found-when-calling-country-index

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!