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/"
}
}
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?
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.
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.
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"
}
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With