I’m new to Yii and my question trivial but I can’t solve this problem:
Yii don’t include file with model class (extends CActiveRecord) when it in “root/protected/models” folder and throw error "failed to open stream: No such file or directory ". When I place file with model class in root folder everything is ok. What’s the reason?
In order to make autoloading working, you need to ensure
[list=1]
[*]classname == filename (if your model class is named MyModel, then it must be saved in a file named MyModel.php)
[*]The folder containing the classes must be importet
[/list]
To configure which folders are importet, you use your application configuration (protected/config/main.php). There should be an entry that looks like:
// autoloading model and component classes
'import'=>array(
'application.models.*', // <-- your models in protected/models should be found
'application.components.*',
),