yidas/yii2-bower-asset 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yidas/yii2-bower-asset

Composer 安装命令:

composer require yidas/yii2-bower-asset

包简介

Bower Assets for Yii 2 app provided via Composer repository

README 文档

README

   

Yii 2 Core Bower Asset


Yii 2 core Bower packages for official Composer repository installation

Latest Stable Version License Total Downloads Monthly Downloads

FEATURES

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

  • Prevent the error of Bower packages when using Composer install & update for Yii2

    Problem 1

    - 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.

  • Official install way by using original Composer repository

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.

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 .

Supported Packages

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

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.

INSTALLATION

1. Require Package

In Yii2 composer.json, require yidas/yii2-bower-asset before yiisoft/yii2.

Example composer.json:

"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.

2. Set Up Application Config

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

$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:

Install via Package Cloning Installer

Install via Alias Setting Installer

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.

Example segament to delete in composer.json :

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

Finally, command composer update then enjoy it.

CREATE PROJECT

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

Create Project via Composer

You can use Composer to create Yii2 project by using following package:

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.

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.

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:

Install via Package Cloning Installer

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

"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.

"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.

LIMITATION

Do not use Bower mixed with Composer project is the goal of this package.

  1. The variety of Bower packages are just for Yii2 cores.

  2. The versions of Bower packages are fixed to current Yii2 version.

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

yidas/yii2-bower-asset 适用场景与选型建议

yidas/yii2-bower-asset 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.3M 次下载、GitHub Stars 达 32, 最近一次更新时间为 2017 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「bower」 「yii2」 「bower asset」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 yidas/yii2-bower-asset 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 yidas/yii2-bower-asset 我们能提供哪些服务?
定制开发 / 二次开发

基于 yidas/yii2-bower-asset 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.3M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 26
  • 依赖项目数: 37
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 1
  • Forks: 13
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-26