Error -Class Yii\db\query Contains 1 Abstract Method

I just installed Yii 2 advanced and I found this error - any clues what does it mean and how to go around it . also my requirement test said I passed the minimum.




 PHP Fatal Error – yii\base\ErrorException

Class yii\db\Query contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (yii\db\QueryInterface::indexBy)


    1. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/Query.php at line 852

    843844845846847848849850851852


                        } else {

                            $this->params[$name] = $value;

                        }

                    }

                }

            }

     

            return $this;

        }

    }


    2. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/BaseYii.php – yii\BaseYii::autoload()

    3. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/BaseYii.php – unknown() at line 285

    4. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/BaseActiveRecord.php – yii\BaseYii::autoload()

    5. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/BaseActiveRecord.php – yii\db\ActiveRecord::find() at line 100

    6. in /Applications/MAMP/htdocs/advanced/common/models/User.php – yii\db\BaseActiveRecord::findOne() at line 91

    85868788899091929394959697


         *

         * @param  string      $username

         * @return static|null

         */

        public static function findByUsername($username)

        {

            return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);

        }

     

        /**

         * Finds user by password reset token

         *

         * @param  string      $token password reset token


    7. in /Applications/MAMP/htdocs/advanced/common/models/LoginForm.php – common\models\User::findByUsername() at line 69

    636465666768697071727374


         *

         * @return User|null

         */

        public function getUser()

        {

            if ($this->_user === false) {

                $this->_user = User::findByUsername($this->username);

            }

     

            return $this->_user;

        }

    }


    8. in /Applications/MAMP/htdocs/advanced/common/models/LoginForm.php – common\models\LoginForm::getUser() at line 40

    34353637383940414243444546


         * Validates the password.

         * This method serves as the inline validation for password.

         */

        public function validatePassword()

        {

            if (!$this->hasErrors()) {

                $user = $this->getUser();

                if (!$user || !$user->validatePassword($this->password)) {

                    $this->addError('password', 'Incorrect username or password.');

                }

            }

        }

     


    9. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/validators/InlineValidator.php – common\models\LoginForm::validatePassword() at line 66

    10. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/validators/InlineValidator.php – call_user_func() at line 66

    11. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/validators/Validator.php – yii\validators\InlineValidator::validateAttribute() at line 234

    12. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Model.php – yii\validators\Validator::validateAttributes() at line 327

    13. in /Applications/MAMP/htdocs/advanced/common/models/LoginForm.php – yii\base\Model::validate() at line 54

    48495051525354555657585960


         * Logs in a user using the provided username and password.

         *

         * @return boolean whether the user is logged in successfully

         */

        public function login()

        {

            if ($this->validate()) {

                return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);

            } else {

                return false;

            }

        }

     


    14. in /Applications/MAMP/htdocs/advanced/frontend/controllers/SiteController.php – common\models\LoginForm::login() at line 80

    74757677787980818283848586


        {

            if (!\Yii::$app->user->isGuest) {

                return $this->goHome();

            }

     

            $model = new LoginForm();

            if ($model->load(Yii::$app->request->post()) && $model->login()) {

                return $this->goBack();

            } else {

                return $this->render('login', [

                    'model' => $model,

                ]);

            }


    15. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/InlineAction.php – frontend\controllers\SiteController::actionLogin() at line 54

    16. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/InlineAction.php – call_user_func_array() at line 54

    17. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Controller.php – yii\base\InlineAction::runWithParams() at line 147

    18. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Module.php – yii\base\Controller::runAction() at line 423

    19. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/web/Application.php – yii\base\Module::runAction() at line 82

    20. in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Application.php – yii\web\Application::handleRequest() at line 353

    21. in /Applications/MAMP/htdocs/advanced/frontend/web/index.php – yii\base\Application::run() at line 17

    11121314151617


        require(__DIR__ . '/../../common/config/main-local.php'),

        require(__DIR__ . '/../config/main.php'),

        require(__DIR__ . '/../config/main-local.php')

    );

     

    $application = new yii\web\Application($config);

    $application->run();


$_GET = array (

  'r' => 'site/login',

);


$_POST = array (

  '_csrf' => 'TXBlNXBQaFN4HCZtSTM5DBs7J2IoGic6JggwfUN9AicbCBx3RAQiEA==',

  'LoginForm' => 

  array (

    'username' => 'xxxxx@xxxxxx.com',

    'password' => 'XXXXX',

    'rememberMe' => '1',

  ),

  'login-button' => '',

);


$_SERVER = array (

  'HTTP_HOST' => 'localhost',

  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:28.0) Gecko/20100101 Firefox/28.0',

  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

  'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',

  'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',

  'HTTP_REFERER' => 'http://localhost/advanced/frontend/web/index.php?r=site/login',

  'HTTP_COOKIE' => 'SQLiteManager_currentLangue=2; PHPSESSID=b42e79d5b91105542d8fc7868005a28f; _csrf=67822ffd64067663f90680453a9d7906829d53642d4e059adea41b9546f4f295s%3A32%3A%225lCX9cQ_VKBWXJOikxUH3-jtVxyB4TJC%22%3B',

  'HTTP_CONNECTION' => 'keep-alive',

  'CONTENT_TYPE' => 'application/x-www-form-urlencoded',

  'CONTENT_LENGTH' => '216',

  'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin',

  'SERVER_SIGNATURE' => '',

  'SERVER_SOFTWARE' => 'Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8y DAV/2 PHP/5.4.10',

  'SERVER_NAME' => 'localhost',

  'SERVER_ADDR' => '::1',

  'SERVER_PORT' => '80',

  'REMOTE_ADDR' => '::1',

  'DOCUMENT_ROOT' => '/Applications/MAMP/htdocs',

  'SERVER_ADMIN' => 'you@example.com',

  'SCRIPT_FILENAME' => '/Applications/MAMP/htdocs/advanced/frontend/web/index.php',

  'REMOTE_PORT' => '53430',

  'GATEWAY_INTERFACE' => 'CGI/1.1',

  'SERVER_PROTOCOL' => 'HTTP/1.1',

  'REQUEST_METHOD' => 'POST',

  'QUERY_STRING' => 'r=site/login',

  'REQUEST_URI' => '/advanced/frontend/web/index.php?r=site/login',

  'SCRIPT_

Hmmm. Either you have obsolete code, or it’s another trait-related thingy.

How did you installed it?

What version of PHP do you have?

I installed in by following the instruction and by using the command line.

here is version details.

‘SERVER_SOFTWARE’ => ‘Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8y DAV/2 PHP/5.4.10’,

can you show your composer.json ? maybe you have installed the yii2-dev package and yii2 is outdated. Try to rm -rf the vendor dir and re-run composer install

If you use MAMP, It’s because of XCache.

Please try to disable it in the MAMP preference.