adding to Yii::app()

how do i add to yii::app

i want to do something like Yii::app()->company = mycompany

no info on the forums just on extending yii::app()->user

thx in advance

The easiest is to add it to the main configuration file (protected/config/main.php), like this:

return array(

	'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

	'name' => 'MyWebApp',

	'company' => 'Me Incorporated',

Then you should be able to use Yii::app()->company.

If you want to extend, use runApplication method. You can pass it a class name.

You can also use params property:

// your application config:


    'company'=>'My Company',


This doesn’t work since $company isn’t a public property of CWebApplication nor does it have a setter-method.

If you really want to access via Yii::app()->company then extend the CWebApplication class (by adding public property or setter/getter method) or attach a behavior to Yii::app(). But maybe what andy_s wrote will work for you.

Right, I still have some Yii learning to do…

That reminds me: I would probably use the Config extension written by Y!! ;)

I am planning to use that myself…

$company = Yii::app()->config->get('company');

Yii::app()->config->set('company', 'My Company Unlimited');