Problem/Motivation

If someone tries to install Drupal core via Composer, it will install it in vendor/drupal/core. To get Drupal installed in the required core folder a custom installer should be provided.

Proposed resolution

Drupal should reference composer/installers as a dependency of a Drupal.

Since it is a dependency of Drupal, not Drupal core, the dependency does not need to be added to the repository and Drupal core makes no assumptions of how it will be installed.

Only when someone executes composer update (from the root of Drupal) will the 3rd-party library be installed. If they never run that command, they'll never get the library.

Steps to test

Inside your Drupal repository root run:

$ rm -r composer.lock core
$ composer install

Afterwards there should be no changes other than in composer.json.

Note that I (tstoeckler) had to also add the following to the repositories section of composer.json:

    {
      "type": "vcs",
      "url": "git@github.com:composer/installers.git"
    }

But it that seems to be a separate issue that I've had before and seems to be somehow related to my environment.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue priority Major because projects should be able to use composer to manage a Drupal project with a minimum of fuss.
Disruption Not disruptive at all - only affects installation of Drupal using composer which atm does not work. This is a step along the way.

Comments

davidwbarratt’s picture

Title: Add composer installer as a dependency of Drupal core, but exclude from the repository. » Add composer installer as a dependency of Drupal
Issue summary: View changes
davidwbarratt’s picture

Title: Add composer installer as a dependency of Drupal » Add Composer Installers as a dependency of Drupal
Priority: Normal » Major
Status: Postponed » Active
davidwbarratt’s picture

Status: Active » Needs review
StatusFileSize
new340 bytes
davidwbarratt’s picture

Issue summary: View changes
davidwbarratt’s picture

Issue summary: View changes

I'm going to assume that the next release will be 1.0.20 when that is released, the version number should be changed to:

^1.0.20

For more information on the Caret operator please see:
https://getcomposer.org/doc/01-basic-usage.md#next-significant-release-t...

davidwbarratt’s picture

Issue summary: View changes
StatusFileSize
new296 bytes

Composer Installers just released 1.0.20 so using that in the version constraint.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Yes, this makes sense. Thanks!

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

Actually, I think we should add the install-paths stuff as well, otherwise adding the installers is kind of pointless.

davidwbarratt’s picture

Status: Needs work » Needs review

#8,

No longer necessary, it's been added to Composer Installers' code base:
https://github.com/composer/installers/pull/208
and is included in the 1.0.20 release (hence the version constraint)

davidwbarratt’s picture

Issue summary: View changes

I've updated this doc with the most recent instructions, if this gets commited I'll update it again:
https://www.drupal.org/node/2404989

tstoeckler’s picture

Ahh yes, I forgot that they provide defaults. I'll give it a spin later to see if it works for me now.

tstoeckler’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Nice, this works really, really well.

As drupal/core is now available on Packagist this actually works.

Updated the issue summary with some steps to test this.

tstoeckler’s picture

Issue summary: View changes
webchick’s picture

Assigned: Unassigned » dries

New external libraries need sign-off from Dries, so assigning. It might be helpful to explain in the issue summary what this gets us (in plain English for the non-Composer-savvy, if possible. :D).

davidwbarratt’s picture

#14,

We're not really adding an external library, just a reference to one (hence why it's in the main composer.json and not core/composer.json).

Does that make sense? Basically only when someone executes composer update will the 3rd-party library be installed. If they never run that command, they'll never get the library.

davidwbarratt’s picture

Title: Add Composer Installers as a dependency of Drupal » Reference Composer Installers as a dependency of a Drupal project
Issue summary: View changes

I've updated the issue summary and title so it makes more sense to the non-Composer folks. :)

davidwbarratt’s picture

Also, we're asking users to add the line anyways:
https://www.drupal.org/node/2404989

alexpott’s picture

Assigned: dries » Unassigned
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

@webchick as @davidwbarratt says this is not adding a new dependency to core - it is part of getting a composer only Drupal project working. So I feel okay to commit this. I've added the beta evaluation to the summary.

Committed c81f327 and pushed to 8.0.x. Thanks!

  • alexpott committed c81f327 on 8.0.x
    Issue #2373197 by davidwbarratt: Reference Composer Installers as a...
davidwbarratt’s picture

Issue summary: View changes

Thanks @alexpott !

I've updated the documentation to reflect the change:
https://www.drupal.org/node/2404989

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.