Bower / bower-asset在php应用程序(例如yii2)中扮演什么角色 [英] what a part does bower/bower-asset play in php application such as yii2
问题描述
最近我部署了一些项目,例如 trntv / yii2-starter-kit 和依此类推。但是所有应用程序都在 @ vendor / bower而不是 @ vendor / bower / bower-asset上发布资产。我已经阅读了问题 Yii2 Composer在bower和bower-中管理软件包供应商并解决了它。但是我仍然对目录 vendor / bower / bower-asset
感到困惑。
bower / bower-asset在php应用程序中起什么作用?它不是一个作曲家程序包,而是其中的许多主题商店。此外, bower
是javascript的依赖项管理,就像 Composer
for PHP一样,但是它如何解决js包的依赖关系由PHP在这种情况下我还没有安装node.js环境?
Recently I deployed some projects like trntv/yii2-starter-kit and so on.but all applications are publishing assets on '@vendor/bower' instead of'@vendor/bower/bower-asset'. I have read the question Yii2 Composer manage package in bower and bower-vendor and solved it . but I still feel confused about the directory vendor/bower/bower-asset
.
What's the part does bower/bower-asset play in php application? it is not a composer package but many theme store in there. Furthermore, bower
is a dependency management for javascript just like Composer
for PHP , but how does it solve dependency for js package by PHP on this occasion that I have not install node.js environment?
推荐答案
Composer Asset Plugin的想法是下载Bower / NPM软件包并管理其依赖性,而无需安装Node JS,Bower和NPM(通过PHP / Composer)。
The idea of Composer Asset Plugin is to download Bower / NPM packages and manage their dependencies without having Node JS, Bower and NPM installed (through PHP / Composer). Also it adds possibility to add JavaScript dependencies for PHP packages that use JavaScript libraries.
例如,请参见 yii2-bootstrap Yii2扩展(PHP)依赖于Bootstrap(JS + CSS):
See for example yii2-bootstrap Yii2 extension (PHP) has a dependency on Bootstrap (JS + CSS):
"bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*"
运行 composer install
或 composer update
时,所有JS依赖项都将安装到 vendor / bower
文件夹中。
When you run composer install
or composer update
, all JS dependencies will be installed to vendor/bower
folder.
这是内置的,但是非常模糊,受到了很多批评,并计划在 2.1.0
中将其删除(据我所知,它已包含在 2.0发行之前
甚至不稳定)。不幸的是,这是必需的,并且没有禁用它的常规方法。
This is built into the core, but very ambiguous, receives a lot of criticism and there are plans to remove it in 2.1.0
(as far as I remember, it was included before release of 2.0
even it was unstable). Unfortunately this is required and there is no normal way to disable it.
您可以在扩展程序的 Github页面。
至于文件夹名称,应将其命名为 bower
,而不是 bower-asset
,如果安装正确的话。
As for folder name, it should be named bower
, not bower-asset
, if you installed everything correctly.
如此自动命名,请确保您具有最新版本的插件:
It's named like so automatically, make sure you have the latest version of plugin:
composer global require "fxp/composer-asset-plugin:~1.1.1"
我甚至建议改用:
composer global require "fxp/composer-asset-plugin:*"
如果有问题或错误,请执行:
If you have problems or errors, execute:
composer global remove "fxp/composer-asset-plugin"
然后重新安装,删除 vendor
和 composer.lock
您的应用程序文件夹并运行:
Then reinstall it again, delete vendor
and composer.lock
in your application folder and run:
composer install
这篇关于Bower / bower-asset在php应用程序(例如yii2)中扮演什么角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!