This blog puts more focus on how to set application level parameters in yii. Its really very simple once you walk through this blog. Its can be done with two quick and easy steps.
Step 1: Add new setting variable.
Once again go to the config folder and open main.php file. Go to the end of file and add following code (modify it as per the need) just before “);”. I have created few variables like “adminEmail”, “settings”, “docrootPath” & “docrootPath2”.
'params' => array( // this is used in contact page 'adminEmail' => 'email@example.com', 'settings' => $settings, 'paths' => array( 'docrootPath' => $docrootPath, 'docrootPath2' => $docrootPath2, ) ),
Step 2: Access newly added variable.
Following code snippet tells you on how to access these global level setting variables inside application.
Yii::app()->params['adminEmail'] // first level Yii::app()->params['paths']['docrootPath'] // inner level variables.
It really easy, isn’t it?.