Yii2 Composer在bower和bower-vendor中管理软件包 [英] Yii2 Composer manage package in bower and bower-vendor
问题描述
我已经有一段时间使用yii2了,但是我无法解决如何管理我的包裹的问题。在这方面,我有两个问题。
I have been using yii2 for sometime now but i cant wrap my head around how to manage my packages. I have two issues in these regard.
-
当我将软件包添加到yii2时,该软件包会下载到供应商/ bower / bower-资产。
when i add a package to yii2 it is downloaded in vendor/bower/bower-assets.
当yii2发布程序包时,它会寻找卖方/卖方的资产
when yii2 is publishing the packages it looks for the assets under vendor/bower
我该如何解决。我为不同的项目安装了许多yii2,似乎每次都遇到相同的问题。
How do i fix this. I have a number of yii2 installations for different projects and i seem to run to the same problem every single time.
这是我的composer.json文件
Here is my composer.json file
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"dektrium/yii2-user": "0.9.*@dev"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
]
},
"extra": {
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
请参阅下文AppAsset文件
See below my AppAsset File
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
推荐答案
可以通过覆盖将其存档凉亭包的默认别名路径是@ vendor / bower到@ vendor / bower / bower-asset。
This can be archived by overwriting the default alias path for bower packages which is @vendor/bower to @vendor/bower/bower-asset.
这可以从$。$$下的web.php文件中完成。 config = []
This can be done from the web.php file under $config=[]
'aliases' => [
'@bower' => '@vendor/bower/bower-asset',
],
当您回显
echo Yii::getAlias('@bower');
它应该回显
/Library/WebServer/Documents/project-name/vendor/bower/bower-asset
这篇关于Yii2 Composer在bower和bower-vendor中管理软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!