Home  >  Article  >  PHP Framework  >  How to install yii2-adminlte

How to install yii2-adminlte

藏色散人
藏色散人Original
2020-01-21 13:03:352961browse

How to install yii2-adminlte

How to install yii2-adminlte? Install AdminLTE and yii2-admin [Version 2.0]

1. Install AdminLTE rendering backend

1. Use AdminLTE rendering backend template

AdminLTE is a fully responsive admin template. Based on Bootstrap3 framework, easy to customize templates. Fits a variety of screen resolutions, from small mobile devices to large desktops. It has multiple built-in pages, including dashboard, email, calendar, lock screen, login and registration, 404 error, 500 error and other pages.

Enter cmd, switch to the advanced directory, enter

composer require dmstr/yii2-adminlte-asset "2.*"

Copy vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app to backend/views/, need to be overwritten The coverage is

2. Enter the backend 127.0.0.1/advanced/backend/web/ to view the effect

3. URL beautification

① Configuration: backend/config/main. php file components

"urlManager" => [
    //用于表明 urlManager 是否启用URL美化功能
    "enablePrettyUrl" => true,
    // 是否在URL中显示入口脚本
    "showScriptName" => false,
],

② Download the .htaccess file and place it in the backend/web directory (this is to hide Index.php, apache must enable the rewrite module)

II , Install yii2-admin and integrate rbac

1, yii2-admin is a set of management tools for yii2 rbac, which implements a beautiful interface and complete permission management functions

Enter cmd, switch to the advanced directory, enter

composer require mdmsoft/yii2-admin "2.x-dev"

2. Configure the backend/config/main.php file

"modules" => [
    "admin" => [
        "class" => "mdm\admin\Module",
    ],
],
"aliases" => [
    "@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
],
'as access' => [
    'class' => 'mdm\admin\components\AccessControl',
    'allowActions' => [
        //这里是允许访问的action
        //controller/action
    // * 表示允许所有,后期会介绍这个
        '*'
    ]
],
'components' => [
    "authManager" => [
        "class" => 'yii\rbac\DbManager',
        "defaultRoles" => ["guest"],
    ],
],

3. Import the rbac table

and execute. sql file: vendor/yiisoft/yii2/rbac/migrations/schema-mysql.sql

4. Run 127.0.0.1/advanced/backend/web/admin/route to preview the effect.

Recommended learning: yii tutorial

The above is the detailed content of How to install yii2-adminlte. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn