Yii System Params From Database. Yii::app()->Getparams() Not Giving Results

I have extended CWebApplication as following to add params (Application-level parameters) from database. but as of now, i dont get anything when i try to retrieve params using

echo Yii::app()->params[‘adminMobileNo’];

extended code,

class QelasyApplication extends CWebApplication


    const PARAM_CACHE = 'params';

    public function setParams($value)


        echo 'test 1';


        $params = parent::getParams();


        echo 'test 2';


        $value = Yii::app()->cache->get(self::PARAM_CACHE);

        if ($value === false) {

            $model = new SystemParam();

            $value = $model->getParam();


            echo 'test 3';


            Yii::app()->cache->add(self::PARAM_CACHE, $value, 1800);


        foreach ($value as $k => $v)

            $params->add($k, $v);



in the main index.php



$application = new QelasyApplication($config);


and in a controller, i am trying to access the params as

        Yii::app()->params['abc'] = 123;

        echo Yii::app()->params['basePath'];

        echo Yii::app()->params['abc'];

        echo Yii::app()->params['adminMobileNo'];

//        print_r(Yii::app()->getParams());


but no output it just exits.

even the setParams method isnt running, coz the echo statements inside are not displayed. what could be the reason ?

why can’t you just write a component and include that in your config extending the CWebApplication. I would not recommend it.


could you please provide an example. tnx.

straight forward harness the power of YII


// create a new file and save it

class LoadParams extends CApplicationComponent {


	public function init() {

                // put your code here




// add this in your config/main.php

// The 'loadParams' component will pre-load



// application components



		'class'=>'path.to.LoadParams', // in my case application.components.LoadParams