PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 7, 2022

[FIXED] How to install third party libraries in Drupal 8 with Composer that are not on packagist?

 January 07, 2022     composer-php, drupal, drupal-8, git     No comments   

Issue

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?


Solution

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,


Answered By - melvin
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing