Calling unknown method: yii\web\Application::getSecurity()

Hi I have problem, with moving yii2 application to another computer.

On my original computer everything works fine.

I added code to git and clone it to another computer.

I updated composer (composer update)

Code install

Pages on 2. computer look fine, but when I try to login I get message:


Unknown Method – yii\base\UnknownMethodException

Calling unknown method: yii\web\Application::getSecurity()


    1. in C:\httpd\omg\omg-new\vendor\yiisoft\yii2\base\Component.php at line 285

    276277278279280281282283284285286287288289290291292293294


        public function __call($name, $params)

        {

            $this->ensureBehaviors();

            foreach ($this->_behaviors as $object) {

                if ($object->hasMethod($name)) {

                    return call_user_func_array([$object, $name], $params);

                }

            }

     

            throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");

        }

     

        /**

         * This method is called after the object is created by cloning an existing one.

         * It removes all behaviors because they are attached to the old object.

         */

        public function __clone()

        {

            $this->_events = [];


    2. in C:\httpd\omg\omg-new\common\models\User.php – yii\base\Component::__call() 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->getSecurity()->validatePassword($password, $this->password_hash);

        }

     

        /**

         * Generates password hash from password and sets it to the model

         *

         * @param string $password






How to proceed to solve this error?

Try this:


//Use this on top of the page:


use yii\base\Security;

I cannot think why this would have failed except some of the files have not copied across correctly. Check for vendor\yiisoft\yii2\web\Application.php and make sure that it extends \yii\base\Application, then check for vendor\yiisoft\yii2\base\Application.php and ensure it is present and contains the getSecurity() function. That should give you a clue as to what might or might not be present.