Since Yii 2.0.13 both Basic and Advanced application templates are pre-configured to use asset-packagist.
As you are using the Yii2 Framework and you want to use composer to install the fullcalendar plugin and the needed assets, this should be the recommended procedure:
- (optional) create a basic project template:
composer create-project --prefer-dist yiisoft/yii2-app-basic fullcalendar-yii-basic
- change your working directory to the root directory of your project:
cd fullcalendar-yii-basic
- install the fullcalendar bundle using asset-packagist (already configured when using a Yii 2 project template):
composer require npm-asset/fullcalendar
Source:
You will find the files main.css and main.js in folder vendor/npm-asset/fullcalendar.
To use them in Yii you should create an AssetBundle like this (put it in folder assets):
<?php
namespace app\assets;
use yii\web\AssetBundle;
/**
- Fullcalendar asset bundle.
*/
class FullcalendarAsset extends AssetBundle
{
public $sourcePath = '@npm/fullcalendar';
public $css = [
YII_ENV_DEV ? 'main.css' : 'main.min.css'
];
public $js = [
YII_ENV_DEV ? 'main.js' : 'main.min.js',
YII_ENV_DEV ? 'locales-all.js' : 'locales-all.min.js'
];
}
In your view you have to register that AssetBundle:
<?php
/* @var $this yii\web\View */
use app\assets\FullcalendarAsset;
FullcalendarAsset::register($this);
$this->title = 'My Yii Application';