我收到错误消息" Class ... not found"即使班级存在。该错误发生在yii \ web \ User类中的loginByAccessToken()方法中。可能导致这种情况的任何想法?
public function loginByAccessToken($token, $type = null)
{
/* @var $class IdentityInterface */
$class = $this->identityClass;
$identity = $class::findIdentityByAccessToken($token, $type); // <-- Error occurs here.
if ($identity && $this->login($identity)) {
return $identity;
} else {
return null;
}
}
以下是调试跟踪:
{
name: "PHP Fatal Error"
message: "Class 'common\models\User' not found"
code: 1
type: "yii\base\ErrorException"
file: "C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\web\User.php"
line: 266
stack-trace: [12]
0: "#0 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\filters\auth\AuthMethod.php(50): yii\filters\auth\HttpBasicAuth->authenticate('???', '???', '???')"
1: "#1 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\ActionFilter.php(71): yii\filters\auth\AuthMethod->beforeAction('???')"
2: "#2 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Component.php(541): yii\base\ActionFilter->beforeFilter('???')"
3: "#3 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Component.php(541): ::call_user_func:{C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Component.php:541}('???', '???')"
4: "#4 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Controller.php(263): yii\base\Component->trigger('???', '???')"
5: "#5 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\web\Controller.php(108): yii\base\Controller->beforeAction('???')"
6: "#6 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Controller.php(149): yii\web\Controller->beforeAction('???')"
7: "#7 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('???', '???')"
8: "#8 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('???', '???')"
9: "#9 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest('???')"
10: "#10 C:\Bitnami\wampstack-5.5.26-0\apache2\htdocs\csplit\api\web\index.php(17): yii\base\Application->run()"
11: "#11 {main}"
-
}
答案 0 :(得分:2)
两个可能的原因。
首先如果您将应用程序从文件夹复制到另一个文件夹,或者如果您在文件夹中添加了扩展名,然后将部分代码复制到另一个文件夹中,则需要执行{{1}在最后的文件夹中。
<强>第二强> 控制User子句使用的命名空间 注意大小写。
答案 1 :(得分:0)
更新复制的类的命名空间后。
您可以在函数规则中编辑SignupForm
类:
'targetClass' => '\common\models\User'
到
'targetClass' => 'app\models\User'