yii-user extension include(WebUser.php)没有这样的文件或目录

unp*_*pix 1 yii yii-extensions

我正在尝试按照此官方教程安装yii-user的扩展

http://www.yiiframework.com/extension/yii-user/#hh2

但是我遇到了一些问题,特别是当我添加它时

 user'=>array(
        // enable cookie-based authentication
        'class' => 'WebUser',
        'allowAutoLogin'=>true,
        'loginUrl' => array('/user/login'),
Run Code Online (Sandbox Code Playgroud)

到配置主.当我添加此代码时,我有此消息错误

include(WebUser.php)[function.include]:无法打开流:没有这样的文件或目录

任何线索?我以前需要做点什么吗?

提前致谢

unp*_*pix 5

我搜索了一下,我找到了解决方案.但它不在文档中.

所以,我们应该在protected/components中创建WebUser.php,如下所示:

  <?php

// this file must be stored in:
// protected/components/WebUser.php

class WebUser extends CWebUser {

// Store model to not repeat query.
 private $UserLogin;

// Return first name.
// access it by Yii::app()->user->first_name
function getFirst_Name(){
$user = $this->loadUserLogin(Yii::app()->user->user_id);
return $user->first_name;
}  

// This is a function that checks the field 'role'
// in the User model to be equal to 1, that means it's admin
// access it by Yii::app()->user->isAdmin()
function isAdmin(){
$user = $this->loadUser(Yii::app()->user->user_id);
return intval($user->user_role_id) == 1;
}

// Load user model.
protected function loadUserLogin($id=null)
{
    if($this->UserLogin===null)
    {
        if($id!==null)
            $this->UserLogin=UserLogin::model()->findByPk($id);
    }
    return $this->UserLogin;
}
}?>
Run Code Online (Sandbox Code Playgroud)

并且应该工作.