SystemicPlural, on 21 July 2010 - 07:32 AM, said:
Yii::import('application.components.myClass.*');
require_once('myClass.php');
Note that this will import the directory
components/myClass/*. If you only want your classfile it's enough to use
Yii::import('application.components.myClass');. But that's probably also obsolete as you already will have Y
ii::import('application.components.*'); in your config.
Quote
Can I lazy load these and access them through Yii::app()-> in some way?
I guess I need to put something in the config, in the components section. But I am not sure what.
Sure, you can configure custom application components. It's best to extend these from CApplicationComponent. Then configure it like this:
'components'=>array(
'somename'=>array(
'class'=>'SomeClass',
'somepublicvar'=>'configvalue',
),
It will be available with
Yii::app()->somename and only be instantiated on first access of this property.