PHPackages                             iamok/yii2-metronic - 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. iamok/yii2-metronic

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

iamok/yii2-metronic
===================

Yii2 集成 Metronic 4.6 主题

1.0.0(8y ago)013BSDPHP

Since Jan 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/wewelove/yii2-metronic)[ Packagist](https://packagist.org/packages/iamok/yii2-metronic)[ RSS](/packages/iamok-yii2-metronic/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

yii2-metronic
=============

[](#yii2-metronic)

[![version](https://camo.githubusercontent.com/d4ce8810c7b59ba8c3086e15b219c62ee688d467be89411d592e4dba5a30dae9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69616d6f6b2f796969322d6d6574726f6e69632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iamok/yii2-metronic)[![Download](https://camo.githubusercontent.com/e1e56381f92b76cf400b9377b88983cb3d4fa2d3e0fccd9dbe1071aedf3c19f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69616d6f6b2f796969322d6d6574726f6e69632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iamok/yii2-metronic)[![Issues](https://camo.githubusercontent.com/0a87257ead87887066657c316b4e4197e4556b1e746bf2478e85fa032e12009f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f776577656c6f76652f796969322d6d6574726f6e69632e7376673f7374796c653d666c61742d737175617265)](https://github.com/wewelove/yii2-metronic/issues)

Yii2 [Metronic theme](http://www.keenthemes.com/) integration. Currently is supported the version 4.6

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

[](#installation)

The extension is in development and the only way to use this fork is through through [composer](http://getcomposer.org/download/).

So add it to your composer.json with this composer command:

```
composer require --prefer-dist iamok/yii2-metronic
```

Then You've to unzip the contents of your metronic Zip theme inside the `@webroot/metronic` folder. Check [Aliases](http://www.yiiframework.com/doc-2.0/guide-concept-aliases.html).

You should have a folder structure like this:

```
* app/
    * web/
        * metronic/
            * _documentation
            * _resources
            * _start
            * theme
            * theme_rtl
```

Quick Start
-----------

[](#quick-start)

Edit your `config/web.php` configuration file and add the metronic component:

```
'components' => [
    'metronic'=>[
        'class'=>'iamok\metronic\Metronic',
        'resources'=>'[path to my web]/web/metronic/assets/theme/assets',
        'style'=>\iamok\metronic\Metronic::STYLE_MATERIAL,
        'theme'=>\iamok\metronic\Metronic::THEME_LIGHT,
        'layoutOption'=>\iamok\metronic\Metronic::LAYOUT_FLUID,
        'headerOption'=>\iamok\metronic\Metronic::HEADER_FIXED,
        'sidebarPosition'=>\iamok\metronic\Metronic::SIDEBAR_POSITION_LEFT,
        'sidebarOption'=>\iamok\metronic\Metronic::SIDEBAR_MENU_ACCORDION,
        'footerOption'=>\iamok\metronic\Metronic::FOOTER_FIXED,

    ],
]
```

**WARNING**Check the "resources" key. This component field is used to locate the content of the zip theme. The component try to create a symlink to this directory inside it's folder. **Eventually this may not work!**In the case the link is invalid, you've to build it by yourself :)

My vendor folder looks like this:

```
* app/
    * [...]
    * vendor/
        * iamok/
            * yii2-metronic/
                * assets -> symlink to /var/www/project/web/metronic/assets/theme/assets
                * builders/
                * bundles/
                * helpers/
                * layouts/
                * widgets/
```

I suggest also to configure the assetManager. My actual configuration is this:

```
'assetManager' => [
        'linkAssets' => true,
        'bundles' => [
            'yii\web\JqueryAsset' => [
                'sourcePath' => null,   // do not publish the bundle
                'js' => [
                    '//code.jquery.com/jquery-1.11.2.min.js',  // use custom jquery
                ]
            ],

            'iamok\metronic\bundles\ThemeAsset' => [
                'addons'=>[
                    'default/login'=>[
                        'css'=>[
                            'pages/css/login-4.min.css',
                        ],
                        'js'=>[
                            'global/plugins/backstretch/jquery.backstretch.min.js',

                        ]
                    ],
                ]
            ],
        ],
    ],
```

In the ThemeAsset class i've added the support for addons. You can specify additional css/js for specific controller/action.

In the example is visible the way to add login-4.min.css and jquery.backstretch.min.js to the login page (in my case, the actionLogin is managed by a controller named DefaultController).

Configuring the layout for your views is the last step.

The metronic component contains a sample layout view. I've not checked it. I'm working on my layout :)

Here is my sample `views/layout/main.php`:

```
