I am trying to figure out Yii/MVC stuff. I have some code/functions that I would like to use by including into a Yii WebApp.
Within the framework design, where would one put user defined include files so that someone who comes into maintain my code go to look for them. I understand I could put them anywhere, but in the directory structure of the framework, what makes sense?
The logic part of an MVC app is described as a model. Now, in Yii terms, a typical model that interacts with a database extends CActiveRecord. Another type of model used for forms can be CActiveForm. So we can accept there are different types of models. For this reason, I use subdirectories in my models folder to seperate the type of model e.g.
protected/
models/
forms/
dbtables/
//.. and so forth
In my main.php config, I then autoload each subdirectory
Since this looks like some configurable things, how about protected/config? There’s no real standard for things like these. You can put wherever you would search for it, when your customer wants a change in 1 year .
I agree, simple strings can be placed in the main.php config file under the params array
'params' => array(
'slogan1' => 'this is a slogan',
'slogan2' => 'this is another slogan'
)
//.. access this is the app like so,
echo Yii::app()->params['slogan1'];
I was just thinking and agree that simple strings could/should go in the ./config/ directory. However I have an encryption class that I like to use, would that file also go in ./config/ ?
Uhm, o.k…? If you will search for texts in /css - go ahead. But should i be the programmer after you, i guarantee that i’ll never find your text configuration there
About the encryption class: I’d rather put it unter components as it’s not a model. Don’t think too much about these decisions. You can easily relocate class files later, when you find out that protected/components gets to crowded.