authManager - chapter 8

Hi - i’m a newbie in web development and I find yii very promising. I can’t complete instruction in chapter 8 because I encounter Property ““CWebApplication.authManager” is read only” error if I add the ff configuration in config/main.php

'authManager'=>array(


        'class'=>'CDbAuthManager',


        'connectionID'=>'db',


    ),

I’m using yii 1.1.8 and windows 7. Thanks.

Hi marvin,

I had a similar problem, and it turned out that it matters where you put the authManager parameter within your config/main.php

mine is underneath components=>array(… and also after the db=>array(… configuration. maybe an example would help?




...

// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

				

		// uncomment the following to enable URLs in path-format

		/*

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),

		*/

		

		/*

		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

		*/

		// uncomment the following to use a MySQL database

		

		'db'=>array(

			'connectionString' => 'mysql:host=localhost;dbname=db_dev',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'xxxxxxxxxxxxxxx',

			'charset' => 'utf8',

		),

		//use authorization Manager for RBAC

		'authManager'=>array(

					'class'=>'CDbAuthManager',

					'connectionID'=>'db',

		),


...




HTH

Hi windsor,

It worked. Thanks a lot.