Drupal 8 Here I come!

So I have a commission to build a Drupal 8 site so off I go. I downloaded Drupal 8 a few months ago when the project was just a gleam in my eye so my first step is to bring it up to speed. This means upgrading from 8.0.6 to 8.1.1 - the current stable release. And the nightmare begins...

Using the usual drush command - drush up - it went from 8.0.6 to 8.0.7. Why? What happened to 8.1.1? Simple question. But the answer was long and complex. The torturous path took me through git upgrades to composer installs to fiddling with drupal-project and Drupal Console. Running through it all were glimpses of drush here and there, broken builds, and the occasional flash of the rabbit's tail as he fled deeper and deeper. One of those moments when even IRC can't help because I don't een know what to ask, to say "How do I fix this?" when I don't know what "this" is. But StackOverFlow and Google are helpful. Drupal.org is a mess. Lots of blog posts but they are all related to how wonderful Drupal 8 is and not to the intricacies of installing and upgrading.

I had good intentions of working out how to do this all with PHPStorm but it just added a layer of complexity that I simply didn't need. I abandoned that part of the process early on.

In part I'm writing this to chart my course with the hope that at the end I have a simple formula that will be useful to others deailing with this new world of drush, composer, and Drupal 8.

Installing the site

My choices were drush, git, or composer with drupal-project. All the cool kids seem to be using composer and after my reading I can see why. It is an easy way to manage something that I have had challenges with in the past - keeping third party software synced with the correct version of other third party software and the modules that require them. I also liked some of the features that I saw emerging with drupal-project. I did have some issues a couple of times in the learning process with the build failing on github but that seemed to be a matter of waiting a day or two and they were resolved.

So the basic command to install Drupal 8 is composer create-project drupal-composer/drupal-project:8.x-dev my_project --stability dev --no-interaction. I played with the command a bit for three reasons:

  1. I wanted to install Drupal in a Project directory that I keep in my /home/ directory. After a bit of fiddling I discovered that if I use a fully qualified path and directory in the place of my_project, things ended up in the right place.
  2. The second issue that I ran into was that the code downloaded was 8.0.x-dev. And I wanted 8.1.1 a stable version. This issue got me digging into the composer.json and Packigist. Suffice to say that Drupal has its own space on packigist and after poking around I found out how to get it working. See updating the code below for the resolution that I finally worked out for this.
  3. The final issue was that I wanted to use an installation profile and this issue got me digging further into the composer.json but had an unhappy ending.

Updating the code

I stumbled into the fact that there were three package managers going on fairly quickly and I thought that adding the repository for the one that wasn't in the initial composer.json was going to solve my problem. It didn't though I learned that I was out on the leading edge. Again.

https://packages.drupal.org/8 (This will be the correct one once it is all working properly.)
https://packagist.drupal-composer.org/packages/drupal/drupal (This is the one currently referenced in the drupal-composer composer.json and it will be deprecated soon.)
https://packagist.org/packages/drupal/drupal (This one is the one developed by composer.)

Eventually I stumbled on two alternatives. Both seem to work. Depending on the package manager chosen you will get slightly different results.

composer require --update-with-dependencies "drupal/core:8.1.*"

composer update drupal/core --with-dependencies

bojanz wrote an excellent article which gave me a lot of insight into the workings of Drupal and composer. The definitive introduction to D8 and Composer explains the intricacies well.

Adding an installation profile

The instructions seemed fairly straightforward for adding an installation profile.

composer require drupal/installation

Didn't work.

So I tried manually editing the composer.json. Still no joy.

"require": {
  "drupal/installation": "^2.0",
}

And then I read this little gem. "Distributions and install profiles are not yet supported." on Using Composer

Good Ole Drush

And so at the end of the day I gave up on git installation and all the fancy composer stuff. And I went with drush.

drush dl drupal-8.1.x

drush dl the_installation

And installed as normal choosing the install profiile when I was ready.