3

Module bootstrap_languages depends on external library of same name how do we ask composer to require the external library that needs to go to libraries/bootstrap_languages folder

The project's composer.json already includes installer-paths but how can I make use of them ?

    "installer-paths": {
        "core": [
            "type:drupal-core"
        ],
        ....
        "libraries/{$name}": [
            "type:drupal-library"
        ]

NOTE: the module itself has not taken care of this dependency

  • Composer will adhere to them automatically. Example, modules will go to modules/contrib, themes go to themes/contrib, etc, depending on what you have in installer-paths. – Kevin May 24 '18 at 19:06
  • so how do I run composer to get the library automatically ? for a module I will say composer require drupal/devel but what do I do for an external library ? – GiorgosK May 24 '18 at 19:07
5

You should be able to include this package via composer by adding some repository info.

Add a package definition to your repositories section in your composer.json. The resulting repositories section may look like this:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "package",
        "package": {
            "name": "usrz/bootstrap-languages",
            "type": "drupal-library",
            "version": "dev-master",
            "dist": {
                "url": "https://github.com/usrz/bootstrap-languages/archive/master.zip",
                "type": "zip"
            }
        }
    }
]

Then you can just use composer require like:

composer require usrz/bootstrap-languages

This will add a new line to your require section in composer.json like

"usrz/bootstrap-languages": "dev-master"

Normally I would try to use this approach with a release tag of a package, rather than the master branch, but no tag exists for this repository.

  • Hi @sonfd Doing this will load the class in all requests or it will Lazy load the class with autoloading? – Beto Aveiga Nov 28 '18 at 17:52
4

You can do this by using Asset Packagist. Add repository and installer-types, installer-paths to your composer.json

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
],
"extra": {
    "installer-types": ["bower-asset", "npm-asset"],
    "installer-paths": {
        "docroot/libraries/{$name}": ["type:drupal-library", "type:bower-asset", "type:npm-asset"]
    },

Then you can add package

composer require bower-asset/bootstrap-language

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.