Zum Inhalt springen

Drupal 8 Website Developer Environments: Unterschied zwischen den Versionen

Aus Computech CMS Wiki
Frederick (Diskussion | Beiträge)
Added Instructions on how to add custom themes from separate repositories to developer environments.
Frederick (Diskussion | Beiträge)
Update structure. Added sections on exporting and importing Drupal configuration.
Zeile 1: Zeile 1:
= Managing Development Environments =
This section describes how to use composer, drush, git and Drupal Configuration Management to move changes between development environments.
== Export main development site configuration to sync directory ==
== 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.
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:
The command export a Drupal 8 website configuration to the configuration sync directory:
drush config-export
The short command is:
  drush cex
  drush cex


Options:
drush config-export options:
* '''--add'''                Run `git add -p` after exporting. This lets you choose which config changes to sync for commit.                   
* '''--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.                               
* '''--branch=<branchname>''' Make commit on provided working branch. Ignored if used without --commit or --push.                               
Zeile 14: Zeile 20:
* '''--skip-modules'''        A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported configuration).
* '''--skip-modules'''        A list of modules to ignore during export (e.g. to avoid listing dev-only modules in exported configuration).


== Add custom theme from separate repository to developer environment ==
To export Drupal configuration and choose changes to commit run:
drush cex --add
 
To export Drupal configuration and commit all changes to current git branch:
drush cex --commit --message "This is the commit message."
 
To export Drupal configuration and commit all changes to current git branch and push to remote git repository:
drush cex --push --message "This is the commit message."
 
After importing Drupal configuration it is always good to '''r'''ebuild a Drupal 8 site and clear all its '''c'''aches with:
drush cache-rebuild
Short form:
drush cr
 
'''NOTE:''' If modules have been installed, updated or removed you will also need to run:
composer install
This will run all the changes in the composer.json file for the project.
 
== Import configuration changes into your developer environment ==
First get the changes from the Git repository and branch. Checkout the branch that you want to get changes from. Then:
git pull
Next import changes into the development environment with:
  drush config-import
Short form:
drush cim
If you would like to see a diff of the changes that will be applied:
drush cim --preview=diff
 
= Add custom theme from separate repository to developer environment =


In the developer environment:
In the developer environment:
Zeile 24: Zeile 58:
  git clone http://192.168.60.12/Bonobo.Git.Server/meostheme.git
  git clone http://192.168.60.12/Bonobo.Git.Server/meostheme.git
   
   
== Copy Drupal 8 Website to developer environments ==
= Copy Drupal 8 Website to developer environments =


* cd in to the new developer environment:
* cd in to the new developer environment:

Version vom 23. Januar 2017, 09:48 Uhr

Managing Development Environments

This section describes how to use composer, drush, git and Drupal Configuration Management to move changes between development environments.

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. The command export a Drupal 8 website configuration to the configuration sync directory:

drush config-export

The short command is:

drush cex

drush config-export 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).

To export Drupal configuration and choose changes to commit run:

drush cex --add

To export Drupal configuration and commit all changes to current git branch:

drush cex --commit --message "This is the commit message."

To export Drupal configuration and commit all changes to current git branch and push to remote git repository:

drush cex --push --message "This is the commit message."

After importing Drupal configuration it is always good to rebuild a Drupal 8 site and clear all its caches with:

drush cache-rebuild

Short form:

drush cr

NOTE: If modules have been installed, updated or removed you will also need to run:

composer install

This will run all the changes in the composer.json file for the project.

Import configuration changes into your developer environment

First get the changes from the Git repository and branch. Checkout the branch that you want to get changes from. Then:

git pull

Next import changes into the development environment with:

 drush config-import

Short form:

drush cim

If you would like to see a diff of the changes that will be applied:

drush cim --preview=diff

Add custom theme from separate repository to developer environment

In the developer environment:

cd themes/custom

Clone repository.

git clone <UrlToRepository>

z.B. MEOS Adminimal Theme

git clone http://192.168.60.12/Bonobo.Git.Server/meostheme.git

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)