I’m pretty helpless about my current problem with yii and so I thought maybe someone can give me a tip. I’ve created a new Component which uses a XML File to find out if User is registered or not. My Problem is that it always says:“Property “CWebApplication.xml” is not defined.” So I think the fault has something to do with my component. Yii seems to do not find the Component, but I don’t know what else to do or why it doesn’t find it.
XML.php --> Component
class Xml extends CApplicationComponent{
private function curl($url, $post=0){
// CURL for XML
return $response;
}
public function login($logout=0, $username="", $password=""){
if ($username && $password){
$response = $this->curl('XMLSheet',
'user='.$username.'&pw='.md5($password).'&login=0'
);
}
else if(isset(Yii::app()->user->id) && !$logout){
$response = $this->curl('XMLSheet',
'user='.Yii::app()->user->name.'&uniqueid='.Yii::app()->user->id.'&login=1&langid=1');
}
else if($logout){
$this->curl('XMLSheet',
'user='.$username.'&login=2');
Yii::app()->user->logout();
return true;
}
else return false;
$xml = new SimpleXMLElement($response);
$user = array(
'errcode'=>(integer) $xml->errcode,
'username'=>(string) $xml->username,
'langid'=>(integer) $xml->langid,
'uniqueid'=>(integer) $xml->uniqueid,
);
Yii::app()->user->setState('errcode',$user['errcode']);
Yii::app()->user->setState('balance',$user['balance']);
return $user;
}
}
Yes the file is in protected/components… I’ve tryed to create an simple HelloWorld component but it also doesn’t work. Are there any settings which I could have taken by mistake to disable creating new components?
I don’t know but next I would try to change the name of the component. Calling it xml might be to look for trouble (naming conflicts, reserved words, …).
Edit:
If on Linux you must use exact case of class name for the file name. Also a probable cause would be problem with file/directory permissions.
Thanks for the fast answer. Unfortunally changing the names doesn’t have any effect. In the yii demo the application files are at the same level as the yii framework but I’ve changed that. May this makes the problems? The strange thing is that the user component (similar to the yii demo user component )works fine…
I’ve solved the problem. May I should have posted the whole main.php, because of any reason I can’t remember, I’ve declared a 2nd “components”=>array (row number 389 so I didn’t scroll down there when I’ve found “components” #1)… yii seems to take the latest “components” declaration when it’s defined multiple. Deleting the 2nd “components” solved some problems and now its clear why some things doesn’t work . So no big deal, stupid fault, but thank you a lot for your help.