Skip to main content

Sometimes you might need to download and use a library that is not provided by any composer providers in your Drupal, Symfony or other composer managed PHP project. But this doesn't mean you'll have to resort to downloading and committing the whole folder.

There is an easy way to make composer download your required external libraries by simply telling it what to do. Say I want to download a JS library (ember.js) into my libraries folder. I add the below to the repositories section in my composer.json file and run composer require emberjs/emberjs.

{
        "type": "package",
        "package": {
          "name": "emberjs/emberjs",
          "version": "3.28.9",
          "type": "drupal-library",
          "dist": {
            "url": "https://github.com/emberjs/ember.js/archive/refs/tags/v3.28.9.zip",
            "type": "zip"
          }
        }
      },

This will download the zip file from the URL mentioned and unzip it into the libraries folder. If you want to specify a folder that you want it to be downloaded into, you can add the below in the "package" part.

"extra": {
              "installer-name": "customerfolder/subfolder"
            },

 

x

Work

Therefore logo
80 Atlantic Ave, Toronto, ON Canada
Email: hello@therefore.ca
Call us: +1 4166405376
Linkedin

Let us know how we can help!