2016-03-08 165 views
1

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.'); 
      } 
     } 
    } 

    /** 

會是什麼問題呢?我跑了作曲家更新。爲什麼只有安全性丟失?

+0

你的多行評論前面是否有斜線缺失?什麼是你得到的錯誤信息,我只是看到代碼?代碼是錯誤消息嗎? –

+0

是的斜線缺失這是yii異常,增加了詳細的異常描述。 – MrGapo

回答

1

您應該使用getSecurity()

Yii::$app->getSecurity()->generatePasswordHash($password); 
+0

好吧可以嘗試getSecutiry。 忘了提。在原始開發服務器上,一切工作正常。但是當我git克隆代碼到其他服務器出現問題時。 – MrGapo

+0

一臺服務器是窗口,另一臺是Unix/Linux? – scaisEdge

+0

好吧試試getSecurity() 同樣的問題:調用未知方法:yii \ web \ Application :: getSecurity() 這兩個都是Windows系統。最終安裝將在Linux上進行,但現在要解決問題,我希望雙方都使用相同的系統。 我想有關於作曲家的東西? – MrGapo

-1

這是正確的: 的Yii :: $應用程序?

不是應該的Yii ::應用程序()

我不熟悉2.X呢。

1

好的我發現了一個錯誤。 運行作曲家更新時。它更新的作曲家,但在安裝手冊發現,你必須執行

作曲家全球需要「的FXP /作曲家資產插件:〜1.1.1」

這個選項我在新電腦全新安裝忘記。現在一切正常