当我尝试登录OR注册时,它不起作用.如果我尝试使用错误的凭据登录,则可以正常工作.但如果我使用正确的凭证,则会出错:
对象配置必须是包含"class"元素的数组.
在线错误:
static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
Run Code Online (Sandbox Code Playgroud)
和相关的线
$models = $this->createModels($rows);
Run Code Online (Sandbox Code Playgroud)
我的配置如下
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
],
];
Run Code Online (Sandbox Code Playgroud)
return [
'components' => [
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://mts:123456@localhost:27017/mangodb',
],
'user' => [
'identityClass' => 'common\models\User', // This is your class with IdentityInterface
'enableAutoLogin' => true,
],
],
];
Run Code Online (Sandbox Code Playgroud)
确保您正在使用的 ActiveRecord 对象( 中的对象static::findOne(...)
)是 的一个实例yii\mongodb\ActiveRecord
,而不是 yii\db\ActiveRecord
因为后者使用标准db
组件,我假设您尚未配置。