PHP code example of chervand / yii-access-control

1. Go to this page and download the library: Download chervand/yii-access-control library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chervand / yii-access-control example snippets


    ...
	'components' => [
	    ...
		'authManager' => [
			'class' => 'CDbAuthManager',
			'connectionID' => 'db',
			'itemTable' => 'auth_item',
			'itemChildTable' => 'auth_item_child',
			'assignmentTable' => 'auth_assignment',
			'defaultRoles' => ['guest', 'user', 'support', 'moder', 'admin'],
		],
		...
    ],
    ...

    ...
	'import' => [
	    ...
		'vendor.chervand.yii-access-control.components.*',
		...
	],
	...

class Controller extends CController
{
    ...
	public function filters()
	{
		return [
		    ...
			[
				'AccessControlFilter',
				'message' => Yii::t('app', 'You are not authorized to perform this action.'),
				'exclude' => [
				    'site/index',
                    'site/error'
                ]
			],
			...
		];
	}
	...
}