By lesley n.


2019-03-08 14:54:19 8 Comments

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?

3 comments

@Kevin 2019-03-08 17:21:54

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.

@lesley n. 2019-03-08 17:58:05

This is a good answer, because you give the advice of best practice. So I've learned a lot today. How to add package to composer.json and how to use dev-version with cli command.

@Jonh 2019-03-08 16:28:22

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.

@Kevin 2019-03-08 17:17:46

Just to clarify here, the dev branch for this theme is parallel on both GitHub and drupal.org. Alternatively, one could do composer require drupal/gesso:2.x-dev to get the dev branch. To me it looks exactly the same. So, 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 d.o. at all, 99% of the time they are on packagist (third party vendor). The rare case is when you have a private repo on GitHub, then this is the approach you would want to take.

@Clive 2019-03-08 15:04:23

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

@lesley n. 2019-03-08 15:18:16

on drupal.org the files are from last year and on github from this year. That's why I want to install from github.

@Kevin 2019-03-08 15:46:35

You would have to add the github repo as a new repository item and call it that way. It isn't ideal, and the Gesso theme should have updated its d.o. project as thats where everyone expects to obtain packages. getcomposer.org/doc/05-repositories.md

@Clive 2019-03-08 15:50:22

What @Kevin said. And just to add that when code isn't in a stable branch, it's often because it's not considered to be stable. i.e. don't run it in production without a plenty of testing. You can find out how to add a custom github repository in the composer docs, just make sure you have type: drupal-module if you want it to be moved into the correct folders etc when installing

@kiamlaluno 2019-03-08 15:51:29

@lesleyn. The development snapshot has been updated on February, 2019. If you want to know when the next official release will be made, you can check/ask on the theme issue queue, on drupal.org.

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Support composer_manager AND drupal-composer/drupal-project with contrib module

  • 2019-02-24 17:42:15
  • donquixote
  • 30 View
  • 0 Score
  • 1 Answer
  • Tags:   7 composer

1 Answered Questions

0 Answered Questions

Can I remove dependencies from dependencies via composer?

0 Answered Questions

Drupal install with composer (drupal-project)

1 Answered Questions

1 Answered Questions

[SOLVED] Managing module library dependencies with composer

2 Answered Questions

[SOLVED] Installing a site with composer

  • 2017-10-18 12:01:38
  • rkian
  • 54 View
  • -3 Score
  • 2 Answer
  • Tags:   composer

1 Answered Questions

[SOLVED] how to import library from Github when the installed module in Drupal 8

2 Answered Questions

[SOLVED] Installing Bootstrap theme using Composer

  • 2017-01-17 13:09:17
  • Bishoy
  • 7294 View
  • 7 Score
  • 2 Answer
  • Tags:   theming 8 composer

Sponsored Content