Question

I have a Drupal 8 installation and I like to install a theme from github.com using composer.

It is this theme https://github.com/forumone/gesso

Can anybody help me what I have to add to the composer.json and where?

Was it helpful?

Solution

If you still want download theme from github, you can edit file composer.json by add more repository:

Add this code

 {
    "type": "package",
    "package": {
        "name": "forumone/gesso",
        "version": "2.0",
        "type":"drupal-theme",
        "source": {
            "url": "https://github.com/forumone/gesso.git",
            "type": "git",
            "reference": "8.x-2.x"
        }
    }
}

after

{
    "type": "composer",
    "url": "https://packages.drupal.org/8"
},

and run composer require "forumone/gesso" to download theme and update composer.lock.

OTHER TIPS

Adding this answer for more clarification for future readers:

The theme in question as of this comment date has a stable release from April 2018. But the development branch is active and updated.

In such a case, you would do this to fetch it instead of the latest stable:

composer require drupal/gesso:2.x-dev

To go even further, you can tack a commit sha on the end of the version to 'pin` the code at that commit - unless you want rolling updates from HEAD. This is a versatile option that you can opt for in Composer that is not so known in the Drupal circles.

You don't need to pull from GitHub in this instance. The only time you would want to do this is when a package does not live on drupal.org at all, 99% of the time they are on Packagist (third party packages, like Prophecy etc).

The rare case is when you have a private repo on GitHub/GitLab or elsewhere, then this is the approach you would want to take to fetch it.

You shouldn't use the Github repository, unless you're getting involved in the theme's development - it doesn't contain a composer.json file, so isn't supposed to be installed this way.

You could mess about trying to set it up as a custom repository, but given that this is a theme hosted on (and packaged by) drupal.org, it would be easier to just install it the standard way:

composer require drupal/gesso

In your theme root add composer.json as follow

 {
  "name": "my/theme",
  "description": "Theme.",
  "type": "drupal-theme",
 }

And in your main composer.json(Drupal) under "Repository" section add

{
  "type": "vcs",
  "url": "git@github.com:my/theme.git",
  "no-api": true
}

And then run composer update

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top