Alias "modules.srbac.components.SDbAuthManager" is invalid

Hi,

Thanks for the code!

I’m a Yii newbie and downloaded the srbac version 1.1.1 and have been trying to run it but got some issues.

Since i’m new to yii i’m probably missing some steps or making some config errors somewhere.

It probably is something glaring obvious that i’ve missed or haven’t done.

If anyone could help me to get this up and running i’d be really greateful.

Many thanks.

Bartes

Here’s what I’ve done so far:

updated the config/main.php following the instructions on the install guide pdf.

create the following tables on the database:

tbl_user

AuthAssginment

AuthItem

AuthItemChild

Then updated my config file as follows:

<?php

// uncomment the following to define a path alias

// Yii::setPathOfAlias(‘local’,‘path/to/local-folder’);

// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

'basePath'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


'name'=&gt;'My Web Application',





// preloading 'log' component


'preload'=&gt;array('log'),





// autoloading model and component classes


'import'=&gt;array(


	'application.models.*',


	'application.components.*',


	'application.modules.srbac.controllers.SBaseController', 


),





/*


'modules'=&gt;array(


	// uncomment the following to enable the Gii tool


	


	'gii'=&gt;array(


		'class'=&gt;'system.gii.GiiModule',


		'password'=&gt;'Enter Your Password Here',


	),


	


),


*/





'modules' =&gt; array(





	'gii'=&gt;array(


		'class'=&gt;'system.gii.GiiModule',


		'password'=&gt;'admin',


	),


	


	   'srbac' =&gt; array( 


			 'userclass'=&gt;'User', //default: User 


			 'userid'=&gt;'user_ID', //default: userid 


			 'username'=&gt;'username', //default:username 


			 'debug'=&gt;true, //default :false 


			 'pageSize'=&gt;10, // default : 15 


			 'superUser' =&gt;'Authority', //default: Authorizer 


			 'css'=&gt;'srbac.css',  //default: srbac.css 


			 'layout'=&gt; 


			   'application.views.layouts.main', //default: application.views.layouts.main,  


												 //must be an existing alias 


			 'notAuthorizedView'=&gt; 'srbac.views.authitem.unauthorized', // default:                  


							   //srbac.views.authitem.unauthorized, must be an existing alias 


			 'alwaysAllowed'=&gt;array(   //default: array() 


				'SiteLogin','SiteLogout','SiteIndex','SiteAdmin', 


				'SiteError', 'SiteContact'), 


			 'userActions'=&gt;array('Show','View','List'), //default: array() 


			 'listBoxNumberOfLines' =&gt; 15,  //default : 10 


			 'imagesPath' =&gt; 'srbac.images', // default: srbac.images 


			 'imagesPack'=&gt;'noia', //default: noia 


			 'iconText'=&gt;true, // default : false 


			 'header'=&gt;'srbac.views.authitem.header', //default : srbac.views.authitem.header,  


													  //must be an existing alias 


			 'footer'=&gt;'srbac.views.authitem.footer', //default: srbac.views.authitem.footer,  


													  //must be an existing alias 


			 'showHeader'=&gt;true, // default: false 


			 'showFooter'=&gt;true, // default: false 


			 'alwaysAllowedPath'=&gt;'srbac.components', // default: srbac.components 


													  // must be an existing alias 


		   ) 


	),








// application components


'components'=&gt;array(


	'user'=&gt;array(


		// enable cookie-based authentication


		'allowAutoLogin'=&gt;true,


		'loginUrl' =&gt; array('/user/user/login'),


	),


	


	'authManager'=&gt;array( 


	// Path to SDbAuthManager in srbac module if you want to use case insensitive   


	 //access checking (or CDbAuthManager for case sensitive access checking) 


	'class'=&gt;'modules.srbac.components.SDbAuthManager', 


	// The database component used 


	'connectionID'=&gt;'db', 


	// The itemTable name (default:authitem) 


	//'itemTable'=&gt;'items', 


	'itemTable'=&gt;'AuthItem', 


	// The assignmentTable name (default:authassignment) 


	//'assignmentTable'=&gt;'assignments', 


	'assignmentTable'=&gt;'AuthAssignment', 


	// The itemChildTable name (default:authitemchild) 


	//'itemChildTable'=&gt;'itemchildren', 


	'itemChildTable'=&gt;'AuthItemChild',


  ), 








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


	/*


	'urlManager'=&gt;array(


		'urlFormat'=&gt;'path',


		'rules'=&gt;array(


			'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


		),


	),


	*/


	/*'db'=&gt;array(


		'connectionString' =&gt; 'sqlite:'.dirname(__FILE__).'/&#46;&#46;/data/testdrive.db',


	),*/


	// uncomment the following to use a MySQL database


	


  'db'=&gt;array( 


	'class'=&gt;'CDbConnection', 


	'connectionString'=&gt;'mysql:host=localhost;dbname=testdrive', 


	'username'=&gt;'root', 


	'password'=&gt;'root', 


	'tablePrefix' =&gt; 'tbl_',





  ), 





	


	


	'errorHandler'=&gt;array(


		// use 'site/error' action to display errors


        'errorAction'=&gt;'site/error',


    ),


	'log'=&gt;array(


		'class'=&gt;'CLogRouter',


		'routes'=&gt;array(


			array(


				'class'=&gt;'CFileLogRoute',


				'levels'=&gt;'error, warning',


			),


			// uncomment the following to show log messages on web pages


			/*


			array(


				'class'=&gt;'CWebLogRoute',


			),


			*/


		),


	),


),





// application-level parameters that can be accessed


// using Yii::app()-&gt;params['paramName']


'params'=&gt;array(


	// this is used in contact page


	'adminEmail'=&gt;'webmaster@example.com',


),

);

Then when i go to http://localhost/testdrive/index.php?r=srbac/authitem/frontpage I get the following error message:

CException

Description

Alias "modules.srbac.components.SDbAuthManager" is invalid. Make sure it points to an existing directory or file.

Source File

/Applications/MAMP/htdocs/testdrive/protected/modules/srbac/SrbacModule.php(242)

00230: public function getShowFooter() {

00231: return $this->_showFooter;

00232: }

00233:

00234:

00235:

00236: /**

00237: * Checks if srbac is installed by checking if Auth items table exists.

00238: * @return boolean Whether srbac is installed or not

00239: */

00240: public function isInstalled() {

00241: try {

00242: $tables = Yii::app()->authManager->db->schema->tableNames;

00243: $itemTableName = Yii::app()->authManager->itemTable;

00244: $itemChildTableName = Yii::app()->authManager->itemChildTable ;

00245: $assignmentTableName = Yii::app()->authManager->assignmentTable ;

00246: $tablePrefix = AuthItem::model()->getDbConnection()->tablePrefix;

00247: if(!is_null($tablePrefix)) {

00248: $itemTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$itemTableName);

00249: $itemChildTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$itemChildTableName);

00250: $assignmentTableName = preg_replace(’/{{(.*?)}}/’,$tablePrefix.’\1’,$assignmentTableName);

00251: }

00252: if(in_array($itemTableName, $tables) &&

00253: in_array($itemChildTableName, $tables) &&

00254: in_array($assignmentTableName, $tables)) {

Stack Trace

#0 /Applications/MAMP/htdocs/yii/framework/YiiBase.php(184): YiiBase::import(‘modules.srbac.c…’, true)

#1 /Applications/MAMP/htdocs/yii/framework/base/CModule.php(362): YiiBase::createComponent(Array)

#2 /Applications/MAMP/htdocs/yii/framework/base/CModule.php(86): CModule->getComponent(‘authManager’)

#3 /Applications/MAMP/htdocs/testdrive/protected/modules/srbac/SrbacModule.php(242): CModule->__get(‘authManager’)

#4 /Applications/MAMP/htdocs/testdrive/protected/modules/srbac/controllers/AuthitemController.php(42): SrbacModule->isInstalled()

#5 /Applications/MAMP/htdocs/yii/framework/web/CController.php(298): AuthitemController->beforeAction(Object(CInlineAction))

#6 /Applications/MAMP/htdocs/yii/framework/web/CController.php(278): CController->runAction(Object(CInlineAction))

#7 /Applications/MAMP/htdocs/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#8 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(324): CController->run(‘frontpage’)

#9 /Applications/MAMP/htdocs/yii/framework/web/CWebApplication.php(121): CWebApplication->runController(‘srbac/authitem/…’)

#10 /Applications/MAMP/htdocs/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()

#11 /Applications/MAMP/htdocs/testdrive/index.php(13): CApplication->run()

#12 {main}

Hi,

This is how i fixed the error:

I simply changed the config/main.php:

// application components


'components'=&gt;array(


	'user'=&gt;array(


		// enable cookie-based authentication


		'allowAutoLogin'=&gt;true,


		'loginUrl' =&gt; array('/user/user/login'),


	),


	


	'authManager'=&gt;array( 


	// Path to SDbAuthManager in srbac module if you want to use case insensitive   


	 //access checking (or CDbAuthManager for case sensitive access checking) 


	'class'=&gt;'modules.srbac.components.SDbAuthManager', 


	// The database component used 


	'connectionID'=&gt;'db', 


	// The itemTable name (default:authitem) 


	//'itemTable'=&gt;'items', 


	'itemTable'=&gt;'AuthItem', 


	// The assignmentTable name (default:authassignment) 


	//'assignmentTable'=&gt;'assignments', 


	'assignmentTable'=&gt;'AuthAssignment', 


	// The itemChildTable name (default:authitemchild) 


	//'itemChildTable'=&gt;'itemchildren', 


	'itemChildTable'=&gt;'AuthItemChild',


  ), 

replaced the ‘class’=>‘modules.srbac.components.SDbAuthManager’, line with:

‘class’=>‘application.modules.srbac.components.SDbAuthManager’,

I have the same problem.

I had test the SRBAC extension from v1.1 to 1.3beta.

any ideas ? thks