Application global preferences - best practice

What is best approach to store the application configs, that should be edited by users via web-interface? That's not user-related, just global variables like caching period, number of items in lists etc.

CApplication has "params" property which can be used to store global parameters.

In your app config, you can do the following:

return array(




Then you can put all your parameters in a separate file in params.php like the following:

return array(





In order to read a parameter, you use Yii::app()->params['pageSize'].

thanks, but I want admin to be able to change that… is there any clever way to load params from the DB? For exmple, in he params.php I'll query DB for global params and return them. Will that work either?

Yes, that will work, but not very elegant, because you put complex logic inside a config file. The query also gets executed for every page, unless you use some caching.

An alternative way is to write a static class like UserPreference. You use this class to read and write parameters, instead of relying on app's params.