简体   繁体   English

Yii2 Composer 和 Bower 问题

[英]Yii2 Composer and Bower issue

I am facing a problem during Yii2 installation.我在 Yii2 安装过程中遇到问题。

I have repository on Bitbucket. Its obvious that after git clone/fetch/pull i need to install dependencies.我在 Bitbucket 上有存储库。很明显,在git clone/fetch/pull之后我需要安装依赖项。 Everything that i am trying to do is always inside newly created php 7.2.0 Docker image machine (Bitbucket Pipelines).我想做的一切总是在新创建php 7.2.0 Docker 图像机(Bitbucket 管道)中。 So here is the list of commands that i have:所以这是我拥有的命令列表:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar create-project

My composer.json file is equals to one from official repository .我的composer.json文件等于官方存储库中的一个文件。

The problem is that web/assets directory is lacking of files.问题web/assets目录缺少文件。 It has autogenerated directories and only yii, yii activeForm, captcha, gridView and validation JS files.它有自动生成的目录,只有 yii、yii activeForm、验证码、gridView 和验证 JS 文件。

As i know composer-asset-plugin not used any more.据我所知composer-asset-plugin不再使用了。 At least no mention in installation guide.至少在安装指南中没有提及。 But even if i add php composer.phar global require "fxp/composer-asset-plugin:^1.4.2" it won't fix the issue.但即使我添加php composer.phar global require "fxp/composer-asset-plugin:^1.4.2"它也无法解决问题。 It looks like bower assets can't be compiled or something like that.看起来凉亭资产无法编译或类似的东西。 Maybe i am wrong.也许我错了。 I have no idea why its not working.我不知道为什么它不起作用。 No results during search too.搜索期间也没有结果。

Any ideas?有任何想法吗? Thanks!谢谢!

For people who facing this issue. 对于面临此问题的人。 I've checked everything once more, it should work but it doesn't. 我再次检查了所有内容,它应该可以,但不能。 All essential directories have correct rights. 所有基本目录均具有正确的权限。 Everything is working perfectly except this bower issue. 除了这个凉亭问题,一切都运转良好。 I doublecheck on local PC. 我在本地PC上仔细检查。 Can't reproduce. 无法复制。

However after about 10 takes to fix, it starts working correctly. 但是,经过大约10个修复之后,它才能正常工作。 Maybe it is yii\\web\\AssetManager issue or something, i still don't know, time will show. 也许是yii\\web\\AssetManager问题,或者我仍然不知道,时间会显示出来。

UPD 22.10.2018 UPD 22.10.2018

You just need to add this code to you cofig file and it will fix this issue. 您只需要将此代码添加到cofig文件即可解决此问题。

'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset'
]

It was also added to application templates 它也已添加到应用程序模板中

Issue come when we are using composer 2. Otherwise we can use fxp/composer-asset-plugin.当我们使用 composer 2 时会出现问题。否则我们可以使用 fxp/composer-asset-plugin。 MihaOo answered for basic app. MihaOo 回答了基本应用程序。 For people who are using advanced app can use following configuration.对于使用高级应用程序的人可以使用以下配置。

Update common/config/main.php with following config.使用以下配置更新 common/config/main.php。

'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset',
],

Original config file from yii2 advanced app - configuration file来自 yii2 高级应用程序的原始配置文件 - 配置文件

More information about this - Yii2 Forum有关此的更多信息 - Yii2 论坛

Complete solution in Asset packagelist - Asset packagelist Asset packagelist中的完整解决方案-Asset packagelist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM