Set Param

Hello all I have required your attention on my problem I want to set global params like.

‘params’ => array(

            'adminEmail' => '',

            'CSS_PATH' => Yii::app()->theme->baseUrl."assests",


But cant succeed. Please advice.


You can’t use Yii::app()-> or Yii::getPathOfAlias(‘webroot’) … in the main.php where you config the ‘params’ because the main.php is used on creating the Yii::app().

I prefer to use a component ‘SiteUtil’ with static helper methods instead.

In most cases there are more useful methods to place there.

For example registerLayoutScripts for usage in the layouts/main.php and more.

SiteUtil.php in protected/components

class SiteUtil


    public static function getCssPath()


        return Yii::app()->theme->baseUrl.'/assests',



     public static function registerLayoutScripts()


        Yii::app()->getClientScript()->register ...






Agree But I need the way to create a param for my FILE_URL, That param should include root_path/path_to_theme_folder/header.php,I am new in YII,I can easy manage by define constant in file and include it into main.php but do not want to disturb the structure. Please advice.

And why do you not use a SiteUtil component like I told?

you will not have access to this "Yii::app()->theme->baseUrl" as the application is not created yet as joblo mentioned create component or create a custom helper and use that or else you could hardcode the absolute path in your params something like


I will not recommend this