PHPackages                             myzero1/yii2-theme-layui - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. myzero1/yii2-theme-layui

ActiveYii2-module[Utility &amp; Helpers](/categories/utility)

myzero1/yii2-theme-layui
========================

Simple captcha for yii2.Just add the module in config file and use the widget.

1.0.5(5y ago)0422BSD-3-ClauseJavaScript

Since Nov 2Pushed 5y agoCompare

[ Source](https://github.com/myzero1/yii2-theme-layui)[ Packagist](https://packagist.org/packages/myzero1/yii2-theme-layui)[ RSS](/packages/myzero1-yii2-theme-layui/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (2)

yii2-theme-layui
================

[](#yii2-theme-layui)

yii2-theme-layui,based on [BrotherMa/layuicms2.0](https://github.com/BrotherMa/layuicms2.0) and [yiisoft/yii2-gii](https://github.com/yiisoft/yii2-gii)

Show time
---------

[](#show-time)

[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-101.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-101.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-102.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-102.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-103.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-103.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-104.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-104.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-105.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-105.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-106.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-106.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-107.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-107.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-108.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-108.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-109.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-109.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-110.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-110.png)[![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-111.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-111.png)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require-dev myzero1/yii2-theme-layui： *

```

or add

```
"myzero1/yii2-theme-layui": "*"

```

to the require-dev section of your `composer.json` file.

Setting
-------

[](#setting)

Once the extension is installed, simply modify your application configuration as follows:

#### in main.php

[](#in-mainphp)

```
return [
    ......
    'components' => [
        ......
        'view' => [
            'theme' => [
                'pathMap' => [
                    '@app/views' => '@vendor/myzero1/yii2-theme-layui/src/views', // using the layui theme
                ],
            ],
        ],
        'assetManager' => [
            'class' => 'yii\web\AssetManager',
            'forceCopy' => false,
            // 'linkAssets' => true,//link to assets,no cache.used in develop.
            'bundles'=> [
                'myzero1\layui\assets\php\components\LayoutAsset' => [
                    // 'copyright' => 'copyright @2018-2038 myzero1', // false
                    // 'copyright' => false
                    'noticeUrl' => '/gii',
                    // 'noticeUrl' => false,
                ],
            ],
        ],
        ......
    ],
    ......
    'params' => [
        ......
            'layuiTheme' => [
                'navs' => [
                    "businessManagement" => [
                        'topMenu' => [
                            "menu" => "businessManagement",
                            "title" => "业务管理",
                            "icon" => "&#xe653;",
                            "class" => "layui-icon",
                        ],
                        [
                            "title" => "业务介绍",
                            "icon" => "icon-text",
                            "href" => "/$moduleId/business/introduction",
                            "spread" => false
                        ],
                        [
                            "title" => "CRUD操作",
                            "icon" => "icon-xiugai",
                            "href" => "",
                            "spread" => false,
                            "children" => [
                                [
                                    "title" => "操作初始化",
                                    "icon" => "z1iconfont z1icon-init",
                                    "href" => "/$moduleId/user/init",
                                    "spread" => false
                                ],
                                [
                                    "title" => "列表页面",
                                    "icon" => "&#xe60a;",
                                    "href" => "/$moduleId/z1-user/index",
                                    "spread" => false
                                ],
                            ]
                        ],
                        [
                            "title" => "使用文档",
                            "icon" => "&#xe705;",
                            "href" => "",
                            "spread" => false,
                            "children" => [
                                [
                                    "title" => "字体图标",
                                    "icon" => "icon-mokuai",
                                    "href" => "/$moduleId/doc/icons",
                                    "spread" => false
                                ],
                                [
                                    "title" => "三级联动",
                                    "icon" => "icon-mokuai",
                                    "href" => "/$moduleId/doc/address",
                                    "spread" => false
                                ],
                                [
                                    "title" => "bodyTab",
                                    "icon" => "icon-mokuai",
                                    "href" => "/$moduleId/doc/bodytab",
                                    "spread" => false
                                ],
                                [
                                    "title" => "三级菜单",
                                    "icon" => "icon-mokuai",
                                    "href" => "/$moduleId/doc/nav",
                                    "spread" => false
                                ],
                            ]
                        ],
                    ],
                    "memberCenter" => [
                        'topMenu' => [
                            "menu" => "memberCenter",
                            "title" => "用户中心",
                            "icon" => "icon-icon10",
                            "class" => "seraph icon-icon10",
                        ],
                        [
                            "title" => "用户管理",
                            "icon" => "&#xe66f;",
                            "href" => "/$moduleId/z1-user/index",
                            "spread" => false
                        ],
                        [
                            "title" => "角色管理",
                            "icon" => "&#xe770;",
                            "href" => "/$moduleId/user/role",
                            "spread" => false
                        ]
                    ],
                    "systemeManagement" => [
                        'topMenu' => [
                            "menu" => "systemeManagement",
                            "title" => "系统管理",
                            "icon" => "z1iconfont z1icon-set",
                            "class" => "z1iconfont z1icon-set",
                        ],
                        [
                            "title" => "平台公告",
                            "icon" => "&#xe638;",
                            "href" => "/$moduleId/site/notice",
                            "spread" => false
                        ],
                        [
                            "title" => "403页面",
                            "icon" => "&#xe638;",
                            "href" => "/$moduleId/site/e403",
                            "spread" => false
                        ],
                        [
                            "title" => "404页面",
                            "icon" => "&#xe638;",
                            "href" => "/$moduleId/site/e404",
                            "spread" => false
                        ],
                        [
                            "title" => "500页面",
                            "icon" => "&#xe638;",
                            "href" => "/$moduleId/site/e500",
                            "spread" => false
                        ],
                        [
                            "title" => "登录页面",
                            "icon" => "&#xe638;",
                            "href" => "/$moduleId/site/login",
                            "spread" => false,
                            "target" => "_blank",
                        ],
                    ],
                ],
                'rightNavs' => [
                    [
                        "title" => "个人资料",
                        "icon" => "seraph icon-ziliao",
                        "href" => "/page/user/userInfo.html",
                        "spread" => false
                    ],
                    [
                        "title" => "修改密码",
                        "icon" => "seraph icon-xiugai",
                        "href" => "page/user/changePwd.html",
                        "spread" => false
                    ],
                ],
                'mainUrl' => $this->id . '/site/main',
                'noticeUrl' => $this->id . '/site/notice',
                'copyright' => 'copyright @2018-2028 myzero1',
                'funcSettting' => true,
                'skin' => true,
            ],
        ......
    ],
    ......

];
```

#### in main-local.php

[](#in-main-localphp)

```
......
if (YII_ENV_DEV) {
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1', '::1'],
        'generators' => [
            'z1layui_crud' => [ // generator name
                'class' => 'myzero1\layui\gii\templates\crud\Generator', // generator class
                'templates' => [
                    'default' => '@vendor/myzero1/yii2-theme-layui/src/gii/templates/crud/layui',
                ]
            ],
        ],
    ];
}
......
```

### setting in module

[](#setting-in-module)

in the main.php of module

```
return [
    ......
    'layout' => 'main',// to set theme by setting layout and layoutPath
    'layoutPath' => \Yii::getAlias('@vendor/myzero1/yii2-theme-layui/src/views/layouts'),
    ......
];
```

Usage
-----

[](#usage)

You can then access home page to watch the theme.

```
http://localhost/path/to/index.php

```

You can then access gii page to watch the crud.

```
http://localhost/path/to/index.php?r=gii
OR
http://localhost/path/to/index.php/gii

```

#### select theme

[](#select-theme)

- `use layui`

    You show set the layout as layout in site Controller for index page,in `SiteController ` as flowlling, in view:

    ```
    public function actionIndex()
    {
        $this->layout = 'layout';
        return $this->render('index');
    }

    ```

    [![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-102.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-102.png)

#### use plugins

[](#use-plugins)

- `Add plug-ins to requirements`

    Just add code as flowlling, in view:

    ```

    ```

    `Optional plug-in`

    ```
    \myzero1\layui\assets\php\components\plugins\EchartsAsset::register($this);
    \myzero1\layui\assets\php\components\plugins\SwitchAsset::register($this);
    \myzero1\layui\assets\php\components\plugins\Wysihtml5Asset::register($this);
    \myzero1\layui\assets\php\components\plugins\ZtreeAsset::register($this);
    ```
- `use echart`

    Just add code as flowlling, in view:

    ```

    ```

    [![](https://github.com/myzero1/show-time/raw/master/yii2-theme-layui/screenshot/-111.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-layui/screenshot/-111.png)
- `use wysihtml5`

    Just add code as flowlling, in view:

    ```

    ```

    [![](https://github.com/myzero1/show-time/raw/master/yii2-theme-adminlteiframe/screenshot/401.png)](https://github.com/myzero1/show-time/blob/master/yii2-theme-adminlteiframe/screenshot/401.png)

    You can also use the advanced wysiwyg tool, [yiidoc/yii2-redactor](https://github.com/yiidoc/yii2-redactor)If you want to upload a file,you can try this widget,[kartik-v/yii2-widget-fileinput](https://github.com/kartik-v/yii2-widget-fileinput)You can combine yiidoc/yii2-redactor and kartik-v/yii2-widget-fileinput together.

    ```
