What is the best way to install a third party library in Drupal 8 that is not on packagist?
For example I have the Color Field module, which can use the jQuery Simple Color Picker library to provide a better user experience.
The most obvious solution is to just add the library manually, but that's not really maintainable.
My second idea was to add the git repository to my composer.json, as shown below, but it doesn't work because the target repository doesn't have a composer.json file.
"repositories": [
{
"name": "jquery-simple-color",
"type": "git",
"url": "https://github.com/recurser/jquery-simple-color.git"
}
],
"require": {
"jquery-simple-color/": "1.2.1"
}
Should I just fork the git repository and add a composer.json file there?
As previously mentioned, Composer is a recommended way to install Drupal. However, if, for some reason, you do not want or cannot use Composer, there are other solutions. For example, you can use Drush and install Drupal from the command line.
You was on the right track, in your composer.json you can make your own "packages" for example:
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/simplecolor",
"version": "1.2.1",
"dist": {
"url": "https://github.com/recurser/jquery-simple-color/archive/v1.2.1.zip",
"type": "zip"
},
"type": "drupal-library"
}
}
]
And then include it trough
"jquery/simplecolor": "1.2.1,
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