Controller access behaviors

According this tutorial I try to implement access control for logged users but without success. It throws me an error but I dont understand what is wrong. Error says Setting unknown property: yii\filters\AccessRule::0 in vendor\yiisoft\yii2\base\Component.php
It seems there is missing key or name for some property. But its like on the video.

	public function behaviors()
	{
		return [
			'access' => [
				'class' => AccessControl::class,
				'only' => ['create', 'update', 'delete'],
				'rules' => [
					'actions' => ['create', 'update', 'delete'],
					'allow' => true,
					'roles' => ['@']
				]
			],
			'verbs' => [
				'class' => VerbFilter::className(),
				'actions' => [
					'delete' => ['POST'],
				],
			],
		];
	}

You probably have to add this:
use yii\filters\AccessControl;
Edit: I may be wrong.

/* This post was moved to /Yii 2.0/General Discussions */

I don’t know but perhaps the missing “()” should be “[]” ?

Edit: The video is to extensive. Obviously there’s a lot more code than what you posted. So I think I cannot help. Somebody else?

inside rules there should be another array
https://helperbyte.com/questions/159039/need-help-with-accesscontrol-in-yii-2

1 Like
'rules' => [
	[
        'actions' => ['create', 'update', 'delete'],
	    'allow' => true,
	    'roles' => ['@']
    ]
]