HI我安裝了yii2並編寫了應用程序。我用git。當我將應用程序傳輸到服務器時。一切都很美好。但是,當我嘗試登錄我得到這個消息:Yii2 - 未知屬性 - yii base UnknownPropertyException獲取未知屬性:yii web Application :: security
Unknown Property – yii\base\UnknownPropertyException
獲得未知屬性:警予\網絡\應用::安全
1. in C:\httpd\omg\omg-new\vendor\yiisoft\yii2\base\Component.php at line 142
133134135136137138139140141142143144145146147148149150151
foreach ($this->_behaviors as $behavior) {
if ($behavior->canGetProperty($name)) {
return $behavior->$name;
}
}
}
if (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
}
/**
* Sets the value of a component property.
* This method will check in the following order and act accordingly:
*
* - a property defined by a setter: set the property value
* - an event in the format of "on xyz": attach the handler to the event "xyz"
2. in C:\httpd\omg\omg-new\vendor\yiisoft\yii2\di\ServiceLocator.php – yii\base\Component::__get() at line 72
3. in C:\httpd\omg\omg-new\common\models\User.php – yii\di\ServiceLocator::__get() at line 154
148149150151152153154155156157158159160
*
* @param string $password password to validate
* @return boolean if password provided is valid for current user
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
4. in C:\httpd\omg\omg-new\common\models\LoginForm.php – common\models\User::validatePassword() at line 45
39404142434445464748495051
* @param array $params the additional name-value pairs given in the rule
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) {
$this->addError($attribute, 'Incorrect username or password.');
}
}
}
/**
會是什麼問題呢?我跑了作曲家更新。爲什麼只有安全性丟失?
你的多行評論前面是否有斜線缺失?什麼是你得到的錯誤信息,我只是看到代碼?代碼是錯誤消息嗎? –
是的斜線缺失這是yii異常,增加了詳細的異常描述。 – MrGapo