调用时找不到 Yii2 页面 country/index

Yii2 Page not found when calling country/index

我正在根据 link 中的教程练习使用 Yii2:http://www.yiiframework.com/doc-2.0/guide-start-databases.html

我正在使用高级应用程序 这些是我创建的文件:

frontend/models/Country.php

frontend/controllers/CountryController.php

frontend/views/country/index.php

现在,当我尝试使用 index.php?r=country/index 访问它时,我收到 404 未找到错误 。 但是如果我将 CountryControlleractionIndex 移动到 SiteCountroller 并将其重命名为 actionCountry 并将我的视图文件移动到站点文件夹中(当然还要更改 index.phpcountry.php) 然后我可以成功地看到使用地址 index.php?r=site/country

的国家列表

关于 404 未找到错误的任何想法?

示例在 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 高级应用中)。

我想这就是你说文件内容完全一样的原因,你没有更改默认配置并检查文件夹、文件和 类 的正确名称。