Reputation: 348
HI i installed yii2 and write application. I used git. When I transfer application to the server. Everything looks fine. But when I try to login I get this message:
Unknown Property – yii\base\UnknownPropertyException
Getting unknown property: yii\web\Application::security
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.');
}
}
}
/**
What would be the problem? I ran composer update. Why only security is missing?
Upvotes: 1
Views: 5505
Reputation: 348
OK I found a bug. When running composer update. It update composer but found in installation manual that you have to execute
composer global require "fxp/composer-asset-plugin:~1.1.1"
This option I forget on fresh installation in new computer. Now everything works
Upvotes: 1
Reputation: 1
Is this correct: Yii::$app?
Shouldn't it be Yii::app()
I'm not familiar with 2.x yet.
Upvotes: -1
Reputation: 133400
You should use getSecurity()
Yii::$app->getSecurity()->generatePasswordHash($password);
Upvotes: 1