Composer 在错误的目录中安装 jQuery 组件 [英] Composer installs jQuery components in wrong directory
问题描述
我正在尝试在 CakePHP 应用程序 composer.json 中通过 Composer 安装 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
.我想在 Vendor one 中拥有所有内容,我该如何解决?
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?
推荐答案
components/jquery
包使用 component-installer,它可以从你的 composer.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.
如果您不喜欢这种方法,那么另一种选择是您可以将自己的包存储库添加到您的 composer.json
中,如下所示:
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"
}
}
通过这种方法,composer 会将 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屋!