访问yii2控制器方法时找不到对象

FR *_*TAR 3 php yii yii2 yii2-user

嗨,我是YII 2框架的新手,

我目前正在从以下教程中学习http://www.yiiframework.com/wiki/490/creating-a-simple-crud-app-with-yii2-revised-12-20-2013/

一切正常,但是当我在SiteController.php中创建一个函数时

 public function actionLogin()
    {

        if (!\Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        } else {
            return $this->render('login', [
                'model' => $model,
            ]);
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我按照以下方式从浏览器访问它时,

http:// localhost / basic / web / site / login /

我越来越

找不到对象!在我的浏览器中,但是我可以按照以下网址访问SiteController.php索引函数:http:// localhost / basic / web /

不确定我在这里缺少什么,可以让我知道这个问题吗?

感谢Adavance

编辑:出于调试目的,我将die语句放在\ basic \ web \ index.php中,显然它也未命中该文件

vit*_*_74 5

好。我明白。您不使用.htaccess。请把它.htaccess放在web文件夹中。并且您需要检查Apache模式mod_rewrite现在是否可用。

#Options +FollowSymLinks
#IndexIgnore */*

#RewriteEngine on

# if a directory or a file exists, use it directly
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
#RewriteRule . index.php


    # use mod_rewrite for pretty URL support
    RewriteEngine on
    # If a directory or a file exists, use the request directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Otherwise forward the request to index.php
    RewriteRule . index.php

    # ...other settings...
Run Code Online (Sandbox Code Playgroud)

https://github.com/yiisoft/yii2/blob/master/docs/guide/start-installation.md#recommended-apache-configuration-中查看更多

urlManagercomponents这样的https://yadi.sk/i/TIKuhYPHehMJq

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => true,          
            'rules' => [
                '<_c:[\w\-]+>' => '<_c>/index',
                '<_c:[\w\-]+>/<_a:[\w\-]+>' => '<_c>/<_a>',
                '<_c:[\w\-]+>/<_a:[\w\-]+>/<id:\d+>' => '<_c>/<_a>',
            ],
        ],
Run Code Online (Sandbox Code Playgroud)

这是工作-https://yadi.sk/i/7iOzHBm1ehMFE