Update on Drupal 8 core and Composer

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by tstoeckler on January 14, 2015 at 2:27am

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!

Categories: ,

Comments

Extra

Posted by davidwbarratt on January 14, 2015 at 3:15am

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!

Posted by tstoeckler on January 14, 2015 at 1:26pm

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

Posted by kasperg on February 2, 2015 at 10:27pm

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.

Fixed the links in the

Posted by webflo on November 10, 2015 at 8:49am

Fixed the links in the article. Thanks!

Composer

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /