Composer在错误的目录中安装jQuery组件 [英] Composer installs jQuery components in wrong directory
问题描述
我想通过Composer在CakePHP应用程序,composer.json中安装jQuery组件:
I'm trying to install jQuery components via Composer in CakePHP app, the composer.json:
{
"name": "affiliate",
"require": {
"cakephp/cakephp": "2.5.*",
"cakephp/debug_kit": "2.2.*@dev",
"cakedc/utils": "dev-develop",
"cakedc/search": "dev-develop",
"friendsofcake/crud": "3.*",
"components/jquery": "2.*"
},
"config": {
"vendor-dir": "Vendor/"
}
}
它会在 app / Vendor / components / jquery
,但它还会在APP的根目录 - app / components / jquery
中创建和安装一些文件。
And it installs some files in app/Vendor/components/jquery
, but also it creates and installs some files in APP's root - app/components/jquery
. I would like to have all in Vendor one, how can I fix that?
推荐答案
组件/ jquery
包使用组件安装程序,它可以从您的作曲家.json
指定 component-dir
设置,这是您要放置下载组件的位置 - 例如在 web / assets
文件夹中:
The components/jquery
package uses component-installer, which can read from your composer.json
a specified component-dir
setting which is where you want to put the downloaded components - e.g. in your web/assets
folder:
{
"require": {
"components/jquery": "*"
},
"config": {
"component-dir": "web/assets"
}
}
要阅读更多关于此文档的文档在这里。
To read more about this check out the docs here.
然后,您可以将这些下载的组件文件添加到web / assets添加到.gitignore中,以便不添加包管理器加载的文件。
You can then add those downloaded component files in web/assets to your .gitignore so that you're not adding files which are loaded in by the package manager.
如果你不是这种方法的粉丝,另一个选项是您可以像这样将 cos> cos>添加您自己的包存储库到:
If you're not a fan of this approach, then one other option is that you can add your own package repository to your composer.json
like this:
{
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "2.1.1",
"dist": {
"url": "http://code.jquery.com/jquery-2.1.1.js",
"type": "file"
}
}
}
],
"require": {
"jquery/jquery": "2.1.1"
}
}
使用这种方法,作曲家将JS文件下载到 vendor / jquery / jquery / jquery-2.1.1.js
- 然后可以添加一个符号链接您的www根目录。
With this approach, composer will download the JS file to vendor/jquery/jquery/jquery-2.1.1.js
- you can then add a symlink to this from your www root directory.
这篇关于Composer在错误的目录中安装jQuery组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!