error in chapter 8

My application was working in Chapter 8 but after I started playing around in the shell, I get this error when I load trackstar/index.php

Does anyone understand this?




CException


Property "CWebApplication.authManager" is read only.


/Applications/MAMP/htdocs/framework/base/CModule.php(467)


455         }

456     }

457 

458     /**

459      * Configures the module with the specified configuration.

460      * @param array $config the configuration array

461      */

462     public function configure($config)

463     {

464         if(is_array($config))

465         {

466             foreach($config as $key=>$value)

467                 $this->$key=$value;

468         }

469     }

470 

471     /**

472      * Loads static application components.

473      */

474     protected function preloadComponents()

475     {

476         foreach($this->preload as $id)

477             $this->getComponent($id);

478     }

479 

Stack Trace

#0	

+  /Applications/MAMP/htdocs/framework/base/CModule.php(467): CComponent->__set("authManager", array("class" => "CDbAuthManager", "connectionID" => "db"))

#1	

+  /Applications/MAMP/htdocs/framework/base/CApplication.php(137): CModule->configure(array("name" => "My Web Application", "preload" => array("log"), "import" => array("application.models.*", "application.components.*"), "modules" => array("gii" => array("class" => "system.gii.GiiModule", "password" => "phawq123", "ipFilters" => array("127.0.0.1", "::1"))), ...))

#2	

+  /Applications/MAMP/htdocs/framework/YiiBase.php(118): CApplication->__construct("/Applications/MAMP/htdocs/trackstar/protected/config/main.php")

#3	

+  /Applications/MAMP/htdocs/framework/YiiBase.php(91): YiiBase::createApplication("CWebApplication", "/Applications/MAMP/htdocs/trackstar/protected/config/main.php")

#4	

–  /Applications/MAMP/htdocs/trackstar/index.php(13): YiiBase::createWebApplication("/Applications/MAMP/htdocs/trackstar/protected/config/main.php")

08 defined('YII_DEBUG') or define('YII_DEBUG',true);

09 // specify how many levels of call stack should be shown in each log message

10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

11 

12 require_once($yii);

13 Yii::createWebApplication($config)->run();

Well, it’s giving you that you’re making a call somewhere in your code to try and change the value of CWebApplication.authManager - which is a read-only property of the web application.

Are you using CPhpAuthManager or CDbAuthManager?

It’s definitely worth taking a look at http://www.yiiframework.com/wiki/65/how-to-setup-rbac-with-a-php-file/ if you’re using CPhpAuthmanager. Following that guide will (hopefully) mean you stop getting the read-only error.

Hope that helps

Please check your protected/config/main.php file and ensure you have defined the AuthManager WITHIN the components array and not outside of it. I.E.


// application components

	'components'=>array(

		...

    	...

	 	'authManager'=>array(

			'class'=>'CDbAuthManager',

			'connectionID'=>'db',

		 ),

     	...

if you have defined your ‘authManger’ outside of this components array, this could generate an error similar to what you are seeing.