组件文件:

class MyComponent extends CApplicationComponent
{
    public $someconfig='somedefault';
    public function init() {
         // Init this component
         // $this->someconfig is already available
    }
    public function myfunction() {...} 
}

main配置文件中

// main configuration:
... 
'components'=>array(
     'something'=>array(
         'class'=>'MyComponent',
         'someconfig'=>'someothervalue',
     ),
...

调用:

Yii::app()->something->myfunction();