在Yii2中找不到(#404)

M_I*_*ees 0 php xampp localhost yii2

我从Yii2开始,已经安装了XAMPP,在Yii2项目模板的帮助下创建了一个名为'yiidemo'的基本项目.然后通过这个URL访问Gii http:// localhost:8080/yiidemo/web/index.php?r = gii生成一个示例控制器'问候',但当我点击'试一试'链接时,它显示我跟随错误消息(网址为http:// localhost:8080/yiidemo/web/index.php?r = greeting):

找不到(#404)

这是controllers\greetingController的代码:

<?php

namespace app\controllers;

class greetingController extends \yii\web\Controller
{
    public function actionIndex()
    {
        return $this->render('views/index');
    }

}
Run Code Online (Sandbox Code Playgroud)

这是views\greeting\index.php代码:

<?php
/* @var $this yii\web\View */
?>
<h1>greeting/index</h1>

<p>
    You may change the content of this page by modifying
    the file <code><?= __FILE__; ?></code>.
</p>
Run Code Online (Sandbox Code Playgroud)

任何机构都可以建议如何使用Yii2 hello world示例.

Cly*_*yff 5

控制器需要全部是CamelCase并以大写字母开头.所以在你的情况下,GreetingController(类和文件).

在你的行动中使用:

return $this->render('index');
Run Code Online (Sandbox Code Playgroud)

在此处查看有关如何使用此方法的更多信息.