Hi,
Recently i have migrated from Appserv for PHP to easyPhp Server due to the dead community and they have stop supporting new versions of php. So i have transferred my YII websites as well to the easyPHP root folder. I have configured everything fine but strangely it is giving me errors which i have never encountered before in Appserv.
I am using now YII 1.1.13 version with easy php 5.3.6 … previously i was using php 5.2. with Appserv
The error i am encountering
Fatal error: Class ‘UserIdentity’ not found in C:\AppServ\www\wordconquest\protected\models\LoginForm.php on line 52
All of my yii websites started showing me such kind of errors , i tried many hours but not sure what should i do…
here is my code
<?php
/**
* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
*/
class LoginForm extends CFormModel
{
public $username;
public $password;
public $rememberMe;
private $_identity;
/**
* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
*/
public function rules()
{
return array(
// username and password are required
array('username, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),
);
}
/**
* Declares attribute labels.
*/
public function attributeLabels()
{
return array(
'rememberMe'=>'Remember me next time',
);
}
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
if(!$this->hasErrors())
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect username or password.');
}
}
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=3600*24*1; // 1 days
Yii::app()->user->login($this->_identity,$duration);
return true;
}
else
return false;
}
}
Error i am facing is
_id; } public function getRole() { return $this->_role; } /** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $user_get = $this->username; $pass_get = trim(Administrator::model()->passwordHash($this->password)); //echo $pass_get; $User =Administrator::model()->find(array("condition"=>"email='$user_get' and wordpas='$pass_get' and status='ACTIVE'")); if($User==null) { $User =Administrator::model()->find(array("condition"=>"email='$user_get' and wordpas='$pass_get'")); if($User!=null) $this->errorCode=756; else $this->errorCode=self::ERROR_USERNAME_INVALID; return !$this->errorCode; } $this->_id = $User->id; $this->setState('status', $User->status); $this->errorCode=self::ERROR_NONE; return !$this->errorCode; } }
Fatal error: Class 'UserIdentity' not found in C:\AppServ\www\wordconquest\protected\models\LoginForm.php on line 52