Getting a Drupal 8 Pantheon Site Up-and-Running Locally on Acquia Dev Desktop
One of the common workflows we see among professional developers and students is to create a new Drupal 8 site on Pantheon, then clone the site down to a local machine and get it up-and-running in Acquia Dev Desktop (with a fresh, empty database).
Unfortunately, there's usually a little "trick" involved in getting the Drupal 8 site to install cleanly locally, that involves a Drupal core security mechanism. Drupal core provides the opportunity to set a "hash salt" variable in the settings.php file. This variable is used as a starting point for hashing passwords and other sensitive information. Pantheon injects the "hash salt" value automatically (which is a good thing, security-wise), but the downside of this is that when the site is moved to a local environment, Pantheon's "hash salt" injection isn't available.
The "hash salt" variable doesn't have to be the same on local and Pantheon, so we can easily set a new one on local. If the "hash salt" isn't set on local prior to installation, then the install will fail.
So, to install a cloned Pantheon Drupal 8 site on a local machine using Acquia Dev Desktop (or pretty much any other *AMP stack), we use the following steps:
- Clone the repository.
- Copy sites/example.settings.local.php to sites/default/settings.local.php (ensure this file is .gitignored).
- Add the following to the bottom of sites/default/settings.local.php:
$settings['hash_salt'] = 'some_random_string';
(note that it cannot be an empty string!). - (Acquia Dev Desktop) Import new local site.
- Run the Drupal installer.
If you forget to add the "hash salt" stuff prior to running the installer, you'll likely have to manually empty the database and start all over again...