Problem/Motivation
Composer Behaviors We Want To Support
Install Drupal 8 using Composer:
$ composer create-project drupal/drupal path/to/drupal 8.0.*
$ cd path/to/drupal
$ ./vendor/bin/phpunit -c core/
Travis test here: https://travis-ci.org/paul-m/d8-create-project (updated version: https://travis-ci.org/timmillwood/d8-create-project)
Adding a dependency to Drupal 8 using Composer:
$ cd drupalroot/
$ composer require crell/api-problem
$ ./vendor/bin/phpunit -c core/
Travis test here: https://travis-ci.org/paul-m/d8-drupal-require
Proposed resolution
Remaining tasks
User interface changes
API changes
There are many things Drupal could improve when it comes to its Composer use.
Install Drupal core using Composer
This would allow modules to depend on specific versions of Drupal core, and allow you to download Drupal with Composer.
- #1975220: Allow a Composer user to manage Drupal, modules, and PHP dependencies with a custom root composer.json
- #586146: [policy, no patch] Decide if and how to implement semantic versioning for Drupal 8.x
- #1826054: [Meta] Expose Drupal Components outside of Drupal
- Can you install Drupal 8 using
composer create-project
? Answer here: https://github.com/paul-m/d8-create-project - Can you use Drupal 8 core as a dependency? Answer here: https://github.com/paul-m/d8-require-drupal
Install Drupal contributed projects using Composer
This allows installing Drupal modules and themes with Composer. Modules could also depend on specific versions of the projects as well.
- #1612910: [policy, no patch] Switch to Semantic Versioning for Drupal contrib extensions (modules, themes, etc)
- https://github.com/composer/installers/pull/65
- http://mile23.com/content/install-drupal-8-module-composer
Composer usage in Drupal core
This fixes some of the use of Composer in Drupal core, for additional awesomeness.
- #1398772: Replace .info.yml with composer.json for extensions
- #1475510: Remove external dependencies from the core repo and let Composer manage the dependencies instead
- #1845300: Ease the development cycle and upgrade path by using Composer's autoload.php
- #1818628: Use Composer's optimized ClassLoader for Core/Component classes
- #2703487: Move Drupal.php autoloading from "files" to "classmap"
- #2038135: Use the Composer autoloader to make everything simpler
- #2755739: Simplify ensureHtaccess(), more portable for composer template between 7.x/8.x
- #2755745: Add packaging info to .info.yml files for extensions managed by Composer, allow Update module to work
- #2760467: Improve vendorTestCodeCleanup() with symfony/finder and symfony/filesystem
- #2760547: Add installRequirementsFile(), prepare required folders/files by composer
Use Composer to manage contrib dependencies
These issues deal with contrib modules using Composer to manage their dependencies.
- #1920666: Allow additional external libraries with composer
- #2303777: Allow drupal components to depend on other components outside Drupal
- #2350647: Allow contrib to use libraries via Composer
- #2536576: Add composer_dependency module, have it help users figure out how to install Composer dependencies
- #2609568: Have wikimedia/composer-merge-plugin manage contrib dependencies.
Beta phase evaluation
Issue category | Task because it is improving the use of something to Drupal. |
---|---|
Issue priority | Normal |
Prioritized changes | This is a prioritized change because it improves developer experience, allowing Drupal to be used in a way that is more familiar to the greater PHP community. |
Disruption | Varying levels of disruption. Individual issues within the meta will have to evaluate disruption separately. |
Comments
Comment #0.0
RobLoacha
Comment #0.1
RobLoachUpdated issue summary.
Comment #0.2
RobLoachUpdated issue summary.
Comment #1
RobLoachTagging
Comment #1.0
RobLoachUpdated issue summary.
Comment #2
patcon CreditAttribution: patcon commentedNice. Is there an issue that properly captures the thought below, without polluting another thread?
Relevant excerpt:
#1612910-34: [policy, no patch] Switch to Semantic Versioning for Drupal contrib extensions (modules, themes, etc)
Related: #586146-16: [policy, no patch] Decide if and how to implement semantic versioning for Drupal 8.x
EDIT: Meh. Opened a new issue :)
#2018019: Split core modules into separate repos with independently versioned API's
Comment #2.0
patcon CreditAttribution: patcon commentedUpdated issue summary.
Comment #2.1
RobLoachUpdated issue summary.
Comment #3
Mile23Comment #4
Mile23Added a link to a test I made to validate Drupal 8's use of Composer. https://github.com/paul-m/d8-create-project
Comment #5
Mile23And another one for
composer require
: https://github.com/paul-m/d8-require-drupalComment #6
Mile23Comment #7
Mile23Comment #8
Mile23Comment #9
Les LimAdded beta evaluation.
Comment #10
Les LimComment #11
Mile23Added some behaviors we want to support.
Please discuss these. :-)
Comment #12
MKorostoff CreditAttribution: MKorostoff commentedFor me the big one is
composer require
. Composer is a dependency manager—if I can't use it to add dependencies it's not really much use to me. I would love to see that feature make it in.Comment #13
Mile23Added this test: https://travis-ci.org/paul-m/d8-drupal-require
Comment #14
timmillwoodLooks like this might just be working:
Comment #15
timmillwoodI have run this through travis again and it gets the code ok, but results in two vendor directories '/vendor' and '/core/vendor' which is causing issues.
https://travis-ci.org/timmillwood/d8-create-project
Comment #16
timmillwoodI have opened a new issue to sort out the duplicate vendor directory problem.
#2500295: 'composer install' creates two vendor directories
Comment #17
Mile23Made this: #2536576: Add composer_dependency module, have it help users figure out how to install Composer dependencies
Comment #18
timmillwoodComment #19
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedComment #20
Mile23Ladies and gentlemen, after #2380389: Use a single vendor directory in the root, we have: https://travis-ci.org/paul-m/d8-drupal-require
(Spoiler: It's passing.)
We can now say
composer require crell/api-problem
and it works.https://travis-ci.org/paul-m/d8-create-project still fails, but actually looks solvable.
Comment #21
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedhttps://travis-ci.org/paul-m/d8-create-project fails because the package on packagist is outdated. Just wait a few days and it will work.
Comment #22
Mile23Here's a test that proves that you can (minimally) use core as a dependency of your own project: https://travis-ci.org/paul-m/d8-require-drupal
Comment #23
Mile23Added new child issue: #2609568: Have wikimedia/composer-merge-plugin manage contrib dependencies.
Super easy.
Comment #24
jhedstromComment #25
jhedstromHas anybody looked at how much work it would be for Drupal to discover modules and themes in the
vendor
directory (if it's possible at all)?That would certainly reduce the amount of odd things we have to do to support proper composer use.
Comment #26
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedDiscovery is one problem, but we ship web accessible assets with our modules/themes and deny access to the vendor folder completely.
Comment #27
lpalgarvio CreditAttribution: lpalgarvio commentedCareful that in 8.1-beta2, with zendframework/zend-stdlib 2.7.3, zend-hydrator was still being used, but as of zend-stdlib 3.0.0, it has been deprecated and removed as dependency from zend-stdlib (no longer installed by default).
from stdlib 2.7.3:
That means if some code is using classes from the hydrator, the dependency will need to be added manually to the require in composer or the classes will need to be reworked.
https://api.drupal.org/api/drupal/vendor!zendframework!zend-hydrator!src...
The result -- if you download the 8.1-beta2 tarball, zend-hydrator is included; if you use composer to get drupal8, it will not be included.
more info:
https://github.com/drupal-composer/drupal-project
https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/
Comment #28
RobLoachAdding this to the list:
#2703487: Move Drupal.php autoloading from "files" to "classmap"
Comment #29
RobLoachComment #30
hswong3i CreditAttribution: hswong3i commentedComment #33
Leksat CreditAttribution: Leksat at Amazee Labs commentedHello!
We just noticed that all 8.1.x tags are broken in https://github.com/drupal/core repository.
We did not know where to report this, so posted at https://github.com/drupal/core/issues/1
Also, I'm adding this comment to attract some attention :)
Tags other than 8.1.x look good.
UPD: the issue was fixed by Ryan Aslett.
Comment #35
websiteworkspace CreditAttribution: websiteworkspace commentedthe composer utility and drupal require conflicting PHP settings:
I recently ran into a problem with D8.x image upload that was only fixed by the PHP setting:
allow_url_fopen = Off
which is as documented on drupal.org for D8.x PHP settings requirements (see link):
https://www.drupal.org/docs/7/system-requirements/php#shortlist
Meanwhile the PHP setting above disables the composer utility which throws a specific error message stating that:
allow_url_fopen = On
must be set for it to operate (see composer error text):
Comment #36
Mixologic@DrupalWebsiteBuilder : Drupals recommendation for
allow_url_fopen = Off
is correct for web based php. However, composer is a command line php application, and as such you would typically have a completely separate php.ini for command line applications. If you have one configuration for both CLI php and webserver php, then you will likely encounter conflicts such as this.Comment #37
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedRelated issue: #2906637: [META] Drush and core compatibility is fragile
There is increased urgency for needing composer because "drush pm-upgrade" is in danger of stopping working in D8.
Comment #39
Mile23Heads up: #2958021: Proposal: Composer Support in Core initiative
Comment #41
leymannxIn the first snippet in the description there's written
$ cd path/to/drupal/
whereas in the second snippet there's written$ cd drupalroot/
. Is there supposed to be adrupalroot
folder insidepath/to/drupal
? I know these folder names are placeholders. But shouldn't it be$ cd path/to/drupal/
in both snippets to avoid confusion?Comment #42
joachim CreditAttribution: joachim as a volunteer commentedIs there an issue yet for fixing the problem whereby Drupal contrib projects that have submodules can't be updated painlessly?
E.g. I am on acsf 2.48.0, which is not the latest version, and 'composer update drupal/acsf' says:
> Nothing to install or update
'composer why-not drupal/acsf 2.51.0' gives the answer:
There are circular dependencies between the main module & its submodules, which AFAIK are created by d.org's composer packaging process.
That means that if you don't know about this, you are headdesking because Composer is refusing to install a new version.
If you DO know about this, you have to name ALL submodules when doing a composer update:
> composer update drupal/acsf drupal/acsf_theme drupal/acsf_variables
This is a) a pain, and b) counter-intuitive, and c) ruins the point of Composer being able to manage dependencies.
Comment #43
mmjvb CreditAttribution: mmjvb as a volunteer commentedDoubt very much it is considered a software problem. Suggest to start with `composer prohibits` (why-not) when updating to find out whether there are things blocking the update. Suggest to use --with-dependencies --dry-run on `composer update` to find out what it will do. In the case that only its submodules are effected you can use --with-dependencies. Otherwise advice to whitelist them, possibly with acsf*.
Comment #46
andypostChecked replacement of default autoloader with composer one brings +5-8% of RPS for me
Also https://twitter.com/nmdmatt/status/1328902315164766208 states similar