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

ActiveYii2-extension

dlds/yii2-metronic
==================

Yii2 Metronic theme integration

2.0.14(8y ago)4414.0k—0%48[8 issues](https://github.com/dlds/yii2-metronic/issues)1BSDPHP

Since Jun 17Pushed 7y ago12 watchersCompare

[ Source](https://github.com/dlds/yii2-metronic)[ Packagist](https://packagist.org/packages/dlds/yii2-metronic)[ RSS](/packages/dlds-yii2-metronic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (1)

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

[](#yii2-metronic)

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

Requirements
------------

[](#requirements)

To use this extension it is required to buy own license for Metronic theme from

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:

```
php composer.phar require dlds/yii2-metronic dev-master

```

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'=>'dlds\metronic\Metronic',
        'resources'=>'[path to my web]/web/metronic/assets/theme/assets',
        'style'=>\dlds\metronic\Metronic::STYLE_MATERIAL,
        'theme'=>\dlds\metronic\Metronic::THEME_LIGHT,
        'layoutOption'=>\dlds\metronic\Metronic::LAYOUT_FLUID,
        'headerOption'=>\dlds\metronic\Metronic::HEADER_FIXED,
        'sidebarPosition'=>\dlds\metronic\Metronic::SIDEBAR_POSITION_LEFT,
        'sidebarOption'=>\dlds\metronic\Metronic::SIDEBAR_MENU_ACCORDION,
        'footerOption'=>\dlds\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/
        - dlds/
            - yii2-metronic/
                - assets -&gt; 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
                ]
            ],

            'dlds\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`:

```
