After weeks of back and forth the Drupal 8 core's composer.json file has now been moved to the core directory to facilitate fetching only the contents of the core directory via Composer.
The relevant issue is https://www.drupal.org/node/1975220. A big shoutout to everyone who moved that issue forward, most notably dawidwbaratt, daffie, bojanz and alexpott.
This issue finally makes it possible to work with Git subtree splits of the Drupal core directory without any hacks. As the subtree now contains a composer.json in the root, I've published the subtree split I maintain on Github to Packagist. That means you can now require drupal/core in your composer.json and it just works.
Composer's default of installing everything into the vendor directory does not work for Drupal. The core directory must be called core. And it must be next to sites, modules, etc. To make the directories where Composer places things configurable the Composer installers project exists. After the Drupal core issue mentioned above went in, Composer installers quickly added support for the drupal/core package.
An example composer.json file that puts all this together and lets you truely compose a Drupal site looks incredibly simple as of now (that's the point!):
{
"require": {
"composer/installers": "^1.0.20",
"drupal/core": "8.0.*",
},
"minimum-stability": "dev",
"prefer-stable": true,
}The Composer installers do not only bring support for installing Drupal core into the right place, it can also download modules, themes or installation profiles granted they contain a
composer.json in their root with the right type (for example drupal-module). Luckily, a lot of Drupal 8 modules already follow that new best practice today. Bye, bye drush dl; hello composer require.
The Drupal repository still/also has a composer.json in the root directory, which is to serve as an example similar to the one above. It is not quite up to speed with regards to the Composer installers, but dawidwbaratt has already spotted that and opened an issue.
Finally it seems like things are coming together!
Comments
Extra
You don't need the entire "extra" section anymore. :)
I've updated the doc and the issue to reflect that.
Thanks for all of your help!
Thanks!
Thanks for pointing that out!
I always put my Drupal site in a subdir of the repo in which case that part is required which is why I forget that it actually isn't needed by default. Updated the post.
And thank you for all your efforts!
Great job getting this change
Great job getting this change in.
Just noticed WikiMedia releasing a custom composer installer with support for merging in additional composer.json files. Perhaps that could have proven useful had this not happened.
https://www.drupal.org/node/1975220 > Access denied
Hi tstoeckler,
Are some of the links above meant only for the private group freelinking?
https://www.drupal.org/node/1975220 > https://groups.drupal.org/freelinking/https%3A/%252Fwww.drupal.org/node/...
added support > https://groups.drupal.org/freelinking/https%3A/%252Fgithub.com/composer/...
Packagist >
https://groups.drupal.org/freelinking/https%3A/%252Fpackagist.org/packag...
Thanks in advance ..
no_angel
Fixed the links in the
Fixed the links in the article. Thanks!