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