完全可以理解,找不到“xxx”类。
但是我在下面粘贴了一个空的className,发生在一个简单的REST身份验证的上下文中
PHP Fatal Error
Class '' not found
yii\base\ErrorException
/home/genie/yii-app/vendor/yiisoft/yii2/rest/IndexAction.php
下面的一些代码,但为什么那个人抛出一个像这样的空类名????
处理登录的控制器(用户模型实现identityInterface:
<?php
namespace api\controllers;
use yii;
use yii\rest\ActiveController;
use common\models\User;
class RestController extends ActiveController
{
public $modelClass = '';
// public $modelClass = 'common\models\User';
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['verbs'] = [
'class' => \yii\filters\VerbFilter::className(),
'actions' => [
'index' => ['get', 'head'],
],
];
$behaviors['access'] = [
'class' => \yii\filters\AccessControl::className(),
'only' => ['index'],
'rules' => [
[
'actions' => ['index'],
'allow' => true,
'roles' => ['@'],
],
],
];
$behaviors['authenticator'] = [
'class' => \yii\filters\auth\HttpBasicAuth::className(),
'auth' => function ($username, $password) {
$user = \common\models\User::findByUsername($username);
if ($user ) {
$pass = \common\models\User::validatePassword($password);
if($pass)
return $user;
}
}
];
return $behaviors;
}
}