Error: Object configuration must be an array containing a "class" element.

4,668 views
Skip to first unread message

Stefano Mtangoo

unread,
Feb 3, 2013, 2:42:47 PM2/3/13
to yii-...@googlegroups.com
use the following in config/main.php

return array(
 
'modules' => array(
   
'auth',
 
),
 
'components' => array(
   
'authManager' => array(
     
.....
     
'behaviors' => array(
       
'auth' => array(
         
'class' => 'auth.components.AuthBehavior',
         
'admins'=>array('admin', 'foo', 'bar'), // users with full access
       
),
     
),
   
),
   
'user' => array(
     
'class' => 'auth.components.AuthWebUser',
   
),
 
),
);


I get error

Quote

Object configuration must be an array containing a "class" element.


If I comment line
'admins'=>array('admin', 'foo', 'bar'), // users with full access
error goes off. Is this a bug?

Stefano Mtangoo

unread,
Feb 6, 2013, 2:41:56 AM2/6/13
to yii-auth
Bump!
Anyone to help? What am I missing?

Christoffer Niska

unread,
Feb 6, 2013, 4:33:38 AM2/6/13
to Stefano Mtangoo, yii-auth
Your auth manager is missing the class property, try this:

return array(
  'modules' => array(
    'auth',
  ),
  'components' => array(
    'authManager' => array(
      'class' => 'CachedDbAuthManager',

      'behaviors' => array(
        'auth' => array(
          'class' => 'auth.components.AuthBehavior',
          'admins'=>array('admin', 'foo', 'bar'), // users with full access
        ),
      ),
    ),
    'user' => array(
      'class' => 'auth.components.AuthWebUser',
    ),
  ),
);
-- 
Christoffer Niska
CTO
Nord Software
+358 500 980 565
Runeberginkatu 43 B 12
00100 Helsinki, Finland
-----------------------------------------------------------------------
The information contained in this message, its responses or attachments
are confidential. The message is intended solely for the adressee(s).
If you are not the intended recipient, you are hereby notified that any
use, dissemination, or reproduction is strictly prohibited. If you are
not the intended recipient, please contact the sender by return e-mail
and destroy all copies of the original message. Unlawful use of this
email may be prosecuted.
----------------------------------------------------------------------- 



--
You received this message because you are subscribed to the Google Groups "yii-auth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yii-auth+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Stefano Mtangoo

unread,
Feb 6, 2013, 5:02:26 AM2/6/13
to yii-auth
Hi Chris,

On Feb 6, 12:33 pm, Christoffer Niska
<christoffer.ni...@nordsoftware.com> wrote:
> Your auth manager is missing the class property, try this:
>
> return array(
>   'modules' => array(
>     'auth',
>   ),
>   'components' => array(
>     'authManager' => array(
>       'class' => 'CachedDbAuthManager',
>       'behaviors' => array(
>         'auth' => array(
>           'class' => 'auth.components.AuthBehavior',
>           'admins'=>array('admin', 'foo', 'bar'), // users with full access
>         ),
>       ),
>     ),
>     'user' => array(
>       'class' => 'auth.components.AuthWebUser',
>     ),
>   ),
> );
>
Here is my current config file

'authManager' => array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
'behaviors' => array(
'auth.components.AuthBehavior',
'admins'=>array('admin', ), // users with full access
*/
),
),

and here is full stack of error

CException

Object configuration must be an array containing a "class" element. (/
home/stefano/Documents/developer/www/yii/YiiBase.php:193)

#0 /home/stefano/Documents/developer/www/yii/base/CComponent.php(326):
YiiBase::createComponent(Array)
#1 /home/stefano/Documents/developer/www/yii/base/CComponent.php(297):
CComponent->attachBehavior('admins', Array)
#2 /home/stefano/Documents/developer/www/yii/base/
CApplicationComponent.php(45): CComponent->attachBehaviors(Array)
#3 /home/stefano/Documents/developer/www/yii/web/auth/
CDbAuthManager.php(58): CApplicationComponent->init()
#4 /home/stefano/Documents/developer/www/yii/base/CModule.php(387):
CDbAuthManager->init()
#5 /home/stefano/Documents/developer/www/yii/base/CModule.php(103):
CModule->getComponent('authManager')
#6 /home/stefano/Documents/developer/www/Projects/pecl/protected/
modules/auth/components/AuthWebUser.php(23): CModule-
>__get('authManager')
#7 /home/stefano/Documents/developer/www/yii/base/CModule.php(387):
AuthWebUser->init()
#8 /home/stefano/Documents/developer/www/yii/base/CModule.php(103):
CModule->getComponent('user')
#9 /home/stefano/Documents/developer/www/Projects/pecl/protected/views/
layouts/main.php(57): CModule->__get('user')
#10 /home/stefano/Documents/developer/www/yii/web/
CBaseController.php(126): require('/home/stefano/D...')
#11 /home/stefano/Documents/developer/www/yii/web/
CBaseController.php(95): CBaseController->renderInternal('/home/
stefano/D...', Array, true)
#12 /home/stefano/Documents/developer/www/yii/web/widgets/
CContentDecorator.php(76): CBaseController->renderFile('/home/stefano/
D...', Array, true)
#13 /home/stefano/Documents/developer/www/yii/web/widgets/
CContentDecorator.php(54): CContentDecorator->decorate('
run() #16 /home/stefano/Documents/developer/www/yii/web/
CBaseController.php(300): CBaseController-
>endWidget('CContentDecorat...') #17 /home/stefano/Documents/developer/
www/Projects/pecl/protected/views/layouts/column2.php(37):
CBaseController->endContent() #18 /home/stefano/Documents/developer/
www/yii/web/CBaseController.php(126): require('/home/stefano/D...')
#19 /home/stefano/Documents/developer/www/yii/web/
CBaseController.php(95): CBaseController->renderInternal('/home/
stefano/D...', Array, true) #20 /home/stefano/Documents/developer/www/
yii/web/CController.php(784): CBaseController->renderFile('/home/
stefano/D...', Array, true) #21 /home/stefano/Documents/developer/www/
Projects/pecl/protected/controllers/SiteController.php(72):
CController->render('error', Array) #22 /home/stefano/Documents/
developer/www/yii/web/actions/CInlineAction.php(49): SiteController-
>actionError() #23 /home/stefano/Documents/developer/www/yii/web/
CController.php(308): CInlineAction->runWithParams(Array) #24 /home/
stefano/Documents/developer/www/yii/web/CController.php(286):
CController->runAction(Object(CInlineAction)) #25 /home/stefano/
Documents/developer/www/yii/web/CController.php(265): CController-
>runActionWithFilters(Object(CInlineAction), Array) #26 /home/stefano/
Documents/developer/www/yii/web/CWebApplication.php(282): CController-
>run('error') #27 /home/stefano/Documents/developer/www/yii/base/
CErrorHandler.php(331): CWebApplication->runController('site/error')
#28 /home/stefano/Documents/developer/www/yii/base/
CErrorHandler.php(204): CErrorHandler->render('error', Array) #29 /
home/stefano/Documents/developer/www/yii/base/CErrorHandler.php(129):
CErrorHandler->handleException(Object(CHttpException)) #30 /home/
stefano/Documents/developer/www/yii/base/CApplication.php(720):
CErrorHandler->handle(Object(CExceptionEvent)) #31 [internal
function]: CApplication->handleException(Object(CHttpException)) #32
{main}

> --
> Christoffer Niska
> CTO
> Nord Software
> +358 500 980 565
> christoffer.ni...@nordsoftware.com
> Runeberginkatu 43 B 12
> 00100 Helsinki, Finlandwww.nordsoftware.com
> -----------------------------------------------------------------------
> The information contained in this message, its responses or attachments
> are confidential. The message is intended solely for the adressee(s).
> If you are not the intended recipient, you are hereby notified that any
> use, dissemination, or reproduction is strictly prohibited. If you are
> not the intended recipient, please contact the sender by return e-mail
> and destroy all copies of the original message. Unlawful use of this
> email may be prosecuted.
> -----------------------------------------------------------------------
>

Stefano Mtangoo

unread,
Feb 6, 2013, 5:05:03 AM2/6/13
to yii-auth
You can see it beautifully here http://paste2.org/p/2831582

Stefano Mtangoo

unread,
Feb 7, 2013, 11:22:53 AM2/7/13
to yii-auth
Hi Chris,
did my reply go into your spam folder?

Christoffer Niska

unread,
Feb 8, 2013, 7:25:34 AM2/8/13
to Stefano Mtangoo, yii-auth
Yeah that's what I meant.

-- 
Christoffer Niska
CTO
Nord Software
+358 500 980 565
Runeberginkatu 43 B 12
00100 Helsinki, Finland
-----------------------------------------------------------------------
The information contained in this message, its responses or attachments
are confidential. The message is intended solely for the adressee(s).
If you are not the intended recipient, you are hereby notified that any
use, dissemination, or reproduction is strictly prohibited. If you are
not the intended recipient, please contact the sender by return e-mail
and destroy all copies of the original message. Unlawful use of this
email may be prosecuted.
----------------------------------------------------------------------- 
On Thu, Feb 7, 2013 at 6:22 PM, Stefano Mtangoo <mwinj...@gmail.com> wrote:
Hi Chris,
did my reply go into your spam folder?

Stefano Mtangoo

unread,
Feb 11, 2013, 4:10:21 AM2/11/13
to yii-auth
Got it working. Made fresh web app and did use this working config
'authManager' => array(

Łukasz Wieczorek

unread,
Mar 13, 2013, 7:47:28 PM3/13/13
to yii-...@googlegroups.com, Stefano Mtangoo
Thanks that worked.

Got it like this now:
'authManager' => array(

'behaviors' => array(
'auth' => array(
'class'=>'auth.components.AuthBehavior',
'admins'=>array('admin', 'foo', 'bar'), // users with full access
),
),
),
It's a pity the readme contains misinformation :)
Reply all
Reply to author
Forward
0 new messages