passing parameter to onBeginRequest

How to pass a parameter to routeRequest function in SiteRouter?

I am using onBeginRequest below but I need to send a $SITEID to the Controller. How to pass in?

return array(


‘onBeginRequest’ => array(‘SiteRouter’, ‘routeRequest’),

// preloading 'log' component


// autoloading model and component classes



Is quite strange that you need to do something like that.

What exactly (pratically) are you trying to achive? Is possible that there is some easier solution to your problem.

My application run multiple sites using one Yii app, I need to pass the siteId determined at the first page like this :


  $SITEID = '2';



  $SITEID = '3';



  $SITEID = '4';


in front.php





in main.php

  'onBeginRequest' => array('SiteRouter', 'routeRequest'),

in SiteRouter class


class SiteRouter


  public static function routeRequest($event)


    $sender = &$event->sender;

    //load site settings from database

    $siteModel = Site::model()->findbyPk( <img src='' class='bbc_emoticon' alt='???' />??? how to get $SITEID here <img src='' class='bbc_emoticon' alt='???' />? );


The $SITEID is needed at the start to load the right params from database. How do I pass $SITEID to into the SiteRouter in onBeginRequest?

Any other ways to achieve this?

I’m looking for answers too. Did you solve the above?

I want to pass the timezone for my (multi site) application specified in main.php to a function that uses set_default_timezone() to set the correct timezone before each request using onBeginRequest event handler. I could probably use app()->params too but it would be more elegant to pass it directly to the event handler in this case.

It’s a bit strange that there is no default support for TimeZone configuration already. Perhaps in the next Yii version?

Could you inherit from the Yii application for each domain and override any data in each subclass of application?