Over the past couple of months, I have been facing a similar situation where many developers are unable to set up a local dev box for Drupal 8 on Pantheon server. Pantheon plays a significant role in hosting a website as it has fast set-up to local and best use of drush command to accelerate administrative and development tasks for Drupal sites.

For an introduction to drush command, you can check our previous blog post where we have explained about writing custom Drush commands in Drupal and installing Drupal with Drush. In this post, I will show you how to set up local dev box for Drupal 8. This blog will be helpful for all industry types and individuals, and after completing it you will find yourself at a moderate level of expertise.

Let’s follow the process step-by-step to set up our own local dev box:

Step 1

  • To set up local dev box for Drupal 8 on Pantheon server, go to dev environment of given site
  • Click on code
  • Click on git and copy below command
git clone ssh://codeserver.dev.463157b8-419d-482f-b571-xxxxxxxxx@codeserver.dev.463157b8-419d-482f-b571-3504bb893903.drush.in:2222/~/repository.git nishant-drupal-8

Step 2

  • Then go to your web root i.e. /var/www/html/ and paste the copied command
git clone ssh://codeserver.dev.463157b8-419d-482f-b571-xxxxxxxxx@codeserver.dev.463157b8-419d-482f-b571-3504bb893903.drush.in:2222/~/repository.git nishant-drupal-8

Step 3

  • Meanwhile, create a database for the site in local
mysql -u root -p

Enter the administrator password you set-up during installation

CREATE DATABASE drupal8;

Step 4

  • Download the Pantheon Drush alias from Pantheon Dashboard (https://dashboard.pantheon.io) and place that file to .drush folder

i.e. /home//.drush/

  • Place below code in .drush folder file name as local.aliases.drushrc.php

--------------------------------------------------------------------------

------------------------------------------------------------------------

 

Step 5

 

  • After clone is done, go to /var/www/html/nishant-drupal-8/sites/default/
  • Create new settings.local.php should be an settings.local.php of Drupal 8 Note: Add below code snippet

 

-----------------------------------------------------------------------------

 

-----------------------------------------------------------------------------

 

Step 6

 

  • Create files folder in sites/all/default/
  • Give permission to file folder Chmod 777 -R files/
  • Go to ./drush folder through terminal and type drush cc drush
  • Now on terminal, type drush sa

 

You will get all local aliases, dev aliases, test aliases and live aliases

 

Eg:-

@local.nishant-drupal-8 ← local aliases
@pantheon.nishant-drupal-8.dev ← pantheon dev aliases
@pantheon.nishant-drupal-8.live ← pantheon live aliases
@pantheon.nishant-drupal-8.test ← pantheon live aliases

 

Note: These aliases are important to sync any database and file

Step 7

  • How to sync database from dev to local
drush sql-sync
drush sql-sync @pantheon.nishant-drupal-8.dev @local.nishant-drupal-8

Note: Be careful about source destination

Step 8

  • How to sync files from dev to local
Drush rsync  <source aliases> <destination aliases>
drush rsync @pantheon.nishant-drupal-8.dev:%files @local.nishant-drupal-8 :%files

Note: After syncing files give your files folder 777 permission and clear cache [ sudo chmod 777 -R files/ ].

That’s it. The above set-up is easy for fast development and lets your Pantheon site up on local. Furthermore, these easy to do steps will save a lot of your time in setting up the Pantheon environment to local. Hope you can now easily do it. If you have any suggestions or queries please comment down let me try to answer.

Publishing companies are constantly transforming, and so is development, we, at Valuebound, are one of those companies who specifically help organizations in their path to Digital Transformation. We enhance digital experience for end users, with tailored web applications.

 

 

comments powered by Disqus