2

I'm trying to add Materialize in my Advanced Yii2 Project.

and there is a sample template for this, but i can't even use it in my yii application

http://yii2.themefactory.net/theme/54/material-simple#.ViNmS_krLIU

How can i add materialize css's in my main application?

is there a good tutorial about that?

Thanks

mandev
  • 257
  • 1
  • 5
  • 20

2 Answers2

2

It's quite easy to add materialize framework into your Yii2 App.

First way (Not suggested):

Copy all needed CSS and JS files into your public web directory. Then in your frontend\assets\AppAsset class add the following lines:

public $css = [
    //... another css files
    'css/materialize.min.css'
];


public $js = [
    //... another js files
    'js/materialize.min.js'
];

Another way would be using Yii2's Bower.

Most JavaScript/CSS packages are managed using Bower and/or NPM, instead of Composer. Yii uses the Composer asset plugin to enable managing these kinds of packages through Composer. If your extension depends on a Bower package, you can simply list the dependency in composer.json like the following:

{
// package dependencies
"require": {
    "bower-asset/jquery": ">=1.11.*"
}
}

So:

bower install materialize

More Information (Yii2's Official Document): Bower and NPM Assets


It might also be remarkable that, you can define new Asset Bundle for your app, so, there is no need to modify AppAsset class. To create your own Asset Bundle check the following links:

Defining Asset Bundles and Using Asset Bundles


If you want to Disable bootstrap or JQuery from your app, you can check the following link:

Yii2 disable Bootstrap Js, JQuery and CSS

Community
  • 1
  • 1
Ali MasudianPour
  • 14,329
  • 3
  • 60
  • 62
0

You can use Materialize for Yii2 package.This repo provides an alternative to Bootstrap by implementing Materialize into Yii2.

Other alternative extensions are 1 & 2.