Objective

In this article we will show the steps to setting up a Drupal website in a local development environment using Acquia’s Dev Desktop. Following this setup can save a considerable amount of time and get up and running in about 15-20 minutes. For people interested in being Acquia developers.

We will install and set up a Drupal website from Acquia's cloud hosting and from a downloaded folder to demonstrate setup for these two most common scenarios.

Checklist

Download and install Dev Desktop and follow onscreen instructions to complete the setup process. Integrate Dev Desktop with Acquia Cloud (for installing a website from Acquia cloud only) by adding required information (username, password, Public Key) on Settings >> General. More help in this step could be found at Acquia's Documentation.

  • Protip: Minimum Senior Developer credentials are required to pull from Acquia Cloud.

  • Protip: To set up from a downloaded folder, grab database file. (unless new setup)

Install Site using Dev Desktop

From Acquia cloud, Acquia blog

To setup a remote site from Acquia Cloud, first click “generate cloud sites” button, this is more or less equivalent to generating Drush Aliases, it will also organize all your cloud sites on Dev Desktop along with their links without actually downloading them.

DevDesktop Layout
Everything at one place dev-desktop layout

  1. Pick the website and its environment you wish to install locally. See left red circle.

  2. Click on the Button “Clone this site locally….”. See right red circle.

Cloning from cloud
Cloning cloud site with Dev Desktop

  1. Pick site name, database name, etc. and press ok. Local site setup is complete at this stage.

From local code folder

  1. Click the + button seen in the first diagram and select “Import Local Site” next.

Importing local site
Importing local site with Dev Desktop

  1. Provide code folder, pick name and DB (new for a new site, select for existing).
  2. Drupal setup will begin, follow onscreen instructions and local site setup should be done at this point.

Result

Dev desktop features
Dev Desktop important features

  • The left green circle indicates the white folder icon next to prod; this means we have this site locally installed. To visit click the link inside green circle on the right-hand side. The local codebase folder will open by clicking the link inside blue circle, phpMyAdmin by clicking the link inside the red circle, and a handy shortcut for opening terminal at the file location can also be seen inside the yellow circle.
  • Local site setup is complete, follow steps below to create a development environment.

Configuring local development settings

At this stage, doing git status produces the following result:

Git diff
running git status at this point

Following the processes below will make git diff disappear as well as create a proper debug and suggestions enabled Dev. Environment.

  • docroot/sites/sites.php is created by Dev Desktop, however upon inspecting this, contains only comments. Therefore, it’s safe to delete this file.
  • docroot/sites/default/settings.php appears to have a few changes made during the process. See screenshot below:

Settings File Diff
Dev Desktop Settings file changes
In the above diagram L#810 to L#817 is what dev desktop changed during installation. Save these in a safe spot and remove from this file.

Next Changes below are part of typical Dev Setup Copied below for convenience.

A. settings.local.php

  • In the settings.php, find the lines that refer to settings.local.php and uncomment them.
/**
* Load local development override configuration, if available.
*
* Use settings.local.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing emails, and
* other things that should not happen on development and testing sites.
*
* Keep this code block at the end of this file to take full effect.
*/
if (file_exists(__DIR__ . '/settings.local.php')) {
 include __DIR__ . '/settings.local.php';
}
  • Copy docroot/sites/example.settings.local.php to docroot/sites/default/settings.local.php and open the file to modify it. Under the comment Enable local development services add some lines:
/**
* Enable local development services.
*/
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
  • Add New Lines
// THE NEW LINES ARE BELOW
if (file_exists(__DIR__ . '/services.local.yml')) {
 $settings['container_yamls'][] = __DIR__ . '/services.local.yml';
}
// NEW LINES FINISH

Review the other features of the settings.local.php file. Your life will be easier when $settings['skip_permissions_hardening'] = TRUE;

B. Customize services.local.yml

  • This file is included only on your local development environment, and since it is included after docroot/sites/default/services.yml, you can override values and avoid changing them in the shared file.
parameters:
 twig.config:
   debug: true
   cache: false
  • Remember the lines saved in the second step, L#810 to L#817 from the file docroot/sites/default/settings.php above, place them at the end of docroot/sites/default/settings.local.php.
  • At this point, git status would indicate no changes.

Fixing Head and Remote Uplink

One last remaining side effect of taking the shortcut is that we might lose our remote uplink during this process. Also our repository is most likely hosted over in GitHub. This could be seen by running command git remote -v and git status. Remote Uplink fix

Detached Head fix
Remote Uplink & Head

  • In case it’s a brand new project, then git init and then create the repository on Github first and then follow along to link it to your repository.
  • For an existing project hosted on GitHub, uplink head to your remote repository by running the following command.
git remote set-url origin [email protected]:myCompany/myProject.git
git checkout develop
git pull

Pro Tip: Clicking terminal icon inside Dev Desktop will open terminal inside the docroot of your project. Remember to cd .. to get back to ROOT.

Caxy Interactive is a Custom Software Development Company

See what other services Caxy has to offer.