Answer the question
In order to leave comments, you need to log in
Why is the password hash method not working in yii2?
Hello, I am making a User model. Wrote a method:
public function setPassword($password)
{
$this->password = Yii::$app->security->generatePasswordHash($password);
}
Answer the question
In order to leave comments, you need to log in
1. The fact that it is underlined by phpStorm does not mean that it is a mistake.
2. Add a backslash before Yii or add it to use. Yii came out of nowhere for you.
With incorrect input values, this method (generatePasswordHash) can return an exception, which for good (as Phpstorm says) you need to put a try catch block, or you have a function description at the top and you need to indicate there that your method (setPassword) can return an exception
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question