1

I am facing a difficulties while trying to install the fullcalendar via composer (composer.phar require "bower-asset/fullcalendar"), it is not pulling the main.css and main.js files. So, I have to do this manually by downloading the files from here.

Just wanted to confirm is this a bug or feature?

Thanks

MrAwanish
  • 13
  • 2

1 Answers1

0

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:

  1. (optional) create a basic project template: composer create-project --prefer-dist yiisoft/yii2-app-basic fullcalendar-yii-basic
  2. change your working directory to the root directory of your project: cd fullcalendar-yii-basic
  3. 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';