2017 © Pedro Peláez
 

yii2-extension yii2-bower-asset

Bower Assets for Yii 2 app provided via Composer repository

image

yidas/yii2-bower-asset

Bower Assets for Yii 2 app provided via Composer repository

  • Saturday, April 7, 2018
  • by yidas
  • Repository
  • 1 Watchers
  • 15 Stars
  • 12,495 Installations
  • JavaScript
  • 5 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 52 % Grown

The README.md

   , (*1)

Yii 2 Core Bower Asset


Yii 2 core Bower packages for official Composer repository installation, (*2)

Latest Stable Version License Total Downloads Monthly Downloads, (*3)

FEATURES

  • *Install or update Bower assets for Yii 2 app via Composer **without any plugin (Even v2.0.13 above)*, (*4)

  • Prevent the error of Bower packages when using Composer install & update for Yii2, (*5)

    Problem 1, (*6)

    - yiisoft/yii2 2.0.12 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found., (*7)

  • Official install way by using original Composer repository, (*8)

Got tired of fxp/composer-asset-plugin? It's a good project with nice idea and good implementation. But it has some issues: it slows down composer update a lot and requires global installation, so affects all projects. Also there are Travis and Scrutinizer integration special problems, that are a bit annoying., (*9)

Compare with Asset Packagist, this package only for installing the Bower packages for Yii2 app by using original Composer repository, which goals to makes Bower separated from Composer ., (*10)

Supported Packages

This Bower asset supports Yii 2 core(yiisoft/yii2) such as widgets or validators., (*11)

For the Yii 2 application templates(yii2-app-basic & yii2-app-advanced), this also supports yii2-bootstrap and others for dependent packages such as yii2-debug & yii2-gii., (*12)


INSTALLATION

1. Require Package

In Yii2 composer.json, require yidas/yii2-bower-asset before yiisoft/yii2., (*13)

Example composer.json:, (*14)

"require": {
    "php": ">=5.4.0",
    "yidas/yii2-bower-asset": "~2.0.5",
    "yiisoft/yii2": "~2.0.5",
    "yiisoft/yii2-bootstrap": "~2.0.0"
}

After above setting, you could run composer require yidas/yii2-bower-asset to install the package. It's same as yidas/yii2-composer-bower-skip which makes composer to install and update for Yii2 without Bower plugin., (*15)

2. Set Up Application Config

In Yii2 application config/web.php, added an alias named @bower pointed to @vendor/yidas/yii2-bower-asset/bower:, (*16)

$config = [
    ...
    'aliases' => [
        '@bower' => '@vendor/yidas/yii2-bower-asset/bower'
    ],
    ...
];

This method is the better way with efficient and clean considering. Instead, you could also use installer to set up:, (*17)

Install via Package Cloning Installer, (*18)

Install via Alias Setting Installer, (*19)

3. Remove Composer Asset-Packagist Repositories

If you are using the version 2.0.13 or higher of Yii, you may remove the repositories setting of composer.json to use original Composer repository., (*20)

Example segament to delete in composer.json :, (*21)

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
]

Finally, command composer update then enjoy it., (*22)


CREATE PROJECT

If you doesn't has Yii2 project yet, choose one of below ways to create:, (*23)

Create Project via Composer

You can use Composer to create Yii2 project by using following package:, (*24)

yidas/yii2-app-basic

composer create-project --prefer-dist yidas/yii2-app-basic

yidas/yii2-app-advanced

composer create-project --prefer-dist yidas/yii2-app-advanced

These packages are Yii 2 Application Template with fixed Bower, which including yidas/yii2-bower-asset already., (*25)

Creating Project from Official Site

You could download Yii2 project from official Archive File, then manally install yii2-bower-asset on it by following above instruction., (*26)


INSTALLER USAGE

If you don't want to Set Up Application Config but use installer instead, there are some ways you could chooses one of them to install:, (*27)

Install via Package Cloning Installer

In Yii2 composer.json, add script yidas\\yii2BowerAsset\\Installer::bower in post-package-install & post-package-update event., (*28)

"scripts": {
    "post-package-install": [
         "yidas\\yii2BowerAsset\\Installer::clone"
    ],
    "post-package-update": [
         "yidas\\yii2BowerAsset\\Installer::clone"
    ]
}

Install via Alias Setting Installer

In Yii2 composer.json, add script yidas\\yii2BowerAsset\\Installer::setAlias in post-update-cmd event., (*29)

"scripts": {
    "post-package-install": [
         "yidas\\yii2BowerAsset\\Installer::setAlias"
    ],
    "post-package-update": [
         "yidas\\yii2BowerAsset\\Installer::setAlias"
    ],
    "unset-yii2-bower-asset": [
        "yidas\\yii2BowerAsset\\Installer::unsetAlias"
    ]
}

This installation will modify Yii2 file, you can run composer run-script unset-yii2-bower-asset to recover back., (*30)


LIMITATION

Do not use Bower mixed with Composer project is the goal of this package., (*31)

  1. The variety of Bower packages are just for Yii2 cores., (*32)

  2. The versions of Bower packages are fixed to current Yii2 version., (*33)

  3. If you are requiring other Bower packages in Yii2, you could set the config fit to this package or not to use., (*34)

The Versions

07/04 2018

dev-master

9999999-dev

Bower Assets for Yii 2 app provided via Composer repository

  Sources   Download

MIT BSD-3-Clause

framework yii2 bower bower asset

03/11 2017

2.0.13

2.0.13.0

Bower Assets for Yii 2 app provided via Composer repository

  Sources   Download

MIT

framework yii2 bower bower asset

06/10 2017

2.0.12

2.0.12.0

Bower Assets for Yii 2 app provided via Composer repository

  Sources   Download

MIT BSD-3-Clause

framework yii2 bower bower asset

19/09 2017

2.0.0

2.0.0.0

The easy way to install and update Bower for Yii2 via Composer

  Sources   Download

MIT

framework yii2 bower bower asset