darkair/yii2-admin

Yii2 admin panel extension based on madmin extension

Installs: 19

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-dev-master 2017-01-22 08:46 UTC

This package is not auto-updated.

Last update: 2024-11-23 21:31:05 UTC


README

Yii2 admin panel based on MAdmin backend admin engine and RBAC.

##Install

php composer.phar require dektrium/yii2-rbac:1.0.0-alpha@dev
php composer.phar require darkair/yii2-admin:dev-master

Setup

In config file:

[
    'bootstrap' => ['admin'],
    'modules' => [
        'admin' => [
            'class' => 'darkair\admin\Module',
            'layout' => '@app/views/layouts/admin.twig',   // NOTE: You must make your admin template in advance
            'as access' => [
                'class' => yii\filters\AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['adminAccess'],      // Specify the admin permissions
                    ]
                ]
            ]
        ],
        'YOUR_ADMIN_MODULE' => [
            'class' => 'YOUR_ADMIN_MODULE_CLASS',
            'layout' => '@app/views/layouts/admin.twig',            
        ]
    ]
]

Migrate:

php yii migrate/up --migrationPath=@yii/rbac/migrations

Usage

  1. Create CRUD models via gii. You must to have <YourModel>.php and <YourModel>Search.php classes at least.

  2. Make your admin controller:

class YourAdminController extends \darkair\admin\AdminController
{
    /**
     * @return string Name of managed model
     */
    public function getManagedModelClass()
    {
        return <YourModel>::className();
    }
}
  1. Create rules like this or on another:
Yii::$app->urlManager->addRules([
    '/admin/YOUR_ROUTE/<action:\w+>/' => 'YOUR_ADMIN_MODULE/YOUR_CONTROLLER/<action>',
], false);