Zum Inhalt springen

Drupal 8 Website Developer Environments

Aus Computech CMS Wiki

Export main development site configuration to sync directory

The location of site configuration sync directory should be configured in the settings.php file or settings.local.php. Many are using ../config/sync. This is outside the webroot for security reasons. To export a Drupal 8 website configuration to the configuration sync directory:

drush cex

Options:

  • --add Run `git add -p` after exporting. This lets you choose which config changes to sync for commit.
  • --branch=<branchname> Make commit on provided working branch. Ignored if used without --commit or --push.
  • --commit Run `git add -A` and `git commit` after exporting. This commits everything that was exported without prompting.
  • --destination An arbitrary directory that should receive the exported files. An alternative to label argument.
  • --message Commit comment for the exported configuration. Optional; may only be used with --commit or --push.
  • --push Run `git push` after committing. Implies --commit.
  • --remote=<origin> The remote git branch to use to push changes. Defaults to "origin".
  • --skip-modules A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported configuration).

Copy Drupal 8 Website to developer environments

  • cd in to the new developer environment:
cd /var/www/meos-fh
  • Initialize the folder for git:
git init
  • Add the Git Repository as a remote called origin:
git remote add origin <repository_URL>
  • Pull the repository to the directory:
git pull
  • Check out the development branch dev:
git checkout dev
  • Fix permissions on sites/default so Drupal can write to it:
chmod -R g+w docroot/sites/default/
  • Change to sites/default directory:
cd docroot/sites/default/
  • Copy as settings.local.php from another development site:
cp  /var/www/meos/docroot/sites/default/settings.local.php ./
  • Fix permissions of settings.local.php
chmod u+w settings.local.php
  • Edit the file:
nano settings.local.php

Change database settings to the new database for the website.

  • Change back to the project folder:
cd ../../../
  • Run Composer to install dependencies:
composer install
  • Pull the database from the main development site: Where @meos.fh is the Drush site alias you want to update.(NOTE:Drush shell alias needs to be created in the aliases file in /etc/drush/ for the pull-live.db command to work.)
drush @meos.fh pull-live-db
  • Import the configuration from the config/sync directory with Drush:
drush @meos.fh cim  #(cim is short for config-import)