DEPRECIATED

I was developing these Workflows with Rob 'The Bones' Coppard who is an experienced Drupal Site Administrator, and uses Linux Mint on the local machine.

We have been searching high and low to find a How To which will show the best way to setup a Drupal 8 Workflow for developing a website locally, pushing to Dev or Staged for testing and then on to Production.

We tried using Composer in various ways, but it is very memory hungry, and if run on a Shared Server will overload the memory, and the Hosting Provider will kill all your processes before it has had time to finish the install. Boom! Gone!. We were unable to find any one place to give us the workflow until we came across an excellent presentation from DrupalCon Dublin 2016 here which put us on the right track.

Drupal 8 has a great way of exporting/importing the configuration using Yaml files which makes it a good deal easier to push/pull changes using Git and a remote repository than it did in Drupal 7.

We now use Drush version 8 for administering Drupal 7 and Drush version 9 for administering Drupal 8.

Drush version 9 makes it very easy to administer the Syncronisation of the settings between sites using the cex and cim switche. Unfortunatel doing this will overwrite important settings eg. the site Settings. However forwarned is forarmed! Now in Drupal 8 you can install the Module 'Config Ignore' to add any files you want excluded from the Import. However this is a potential minefield, there are a good few .yml files in the sync folder. which ones to exclude? We have been unable to find anyone who knows, but bys trial and error you would only need one. The 'system.site' file, so all you need to do is add this to the ignore pane in the settings for the module, and is well..

This is aimed at a Linux environment. We are NOT using Windows.

To simplify things in this How To we will just have a Local and Production Site, missing out the Dev/Staged site.

Assumptions

  • You have a LAMP server running Locally with Composer, Drush version 9 installed Globally and Git installed on your Production and Local Servers. Make sure the PHP version matches across Local, Dev and Production and has all the Drupal Requirements.
  • We have found that you should NOT use Composer on a Shared Hosting Server. It will run out of memory and then you are in the poo, so this is why we use Composer locally and git and drush to sync the servers.
  • You are familiar with the basics of Composer, Drush & Git
  • You have some knowledge of using the command line in Linux
  • You can ssh into your Production & Local Servers
  • Our example on the Local Server is using Linux Mint, I use Gentoo as well, you will need to take the OS into consideration for your own situation.

Outline of Workflow

  • Install on Local, Dev and Production
  • Initialise a Git repository in the root of your Local  Server and add the Remote Repo.
  • Then clone the sites so they match. This will sync the UUID of all sites which is ESSENTIAL.
  • Create a remote Git repo for the project and sync all to that repo, and pull to Dev and Production.
  • ========== Local, Dev & Production should match =========

Development Workflow Proper

  • On the Local Server make a change to the site eg. add and enable a module
  • Export the config using Drush cex command
  • Git Commit & Push to remote
  • On the Dev Server Git Pull from remote
  • Import the settings using Drush cim
  • Check everything is working OK
  • On the Production Server Git Pull from remote
  • Import the settings using Drush cim
  • Check everything is working OK
  • ========== Local, Dev & Production should match
  • ======= Without messing up the Production Site Settings

Now for those of you who are impatient we have provided a script which will rip down a Drupal site if already present, and create a new File Based Drupal 8 site with a Git Repository from scratch using Composer and Drush in a little over 3 minutes.

However it might be worth reading our workflow method as well before taking the plunge.