Putting it all Together

Now that we've got everything set up, let's run though a typical workflow scenario. Here's what we'll do:

  • Install new modules with Composer
  • Install a new theme with Composer
  • Enable Admin Toolbar, Admin Toolbar Extra Tools, Pathauto and Devel
  • Set Drupal8 Zymphonies Theme as the default theme
  • Change the temp path on our local site to "/tmp"
  • Create a View of Articles
  • Add a few blocks to various regions
  • Save a Google Analytics account to configuration through the UI
  • Override the GA account with an empty string on development
  • Export the configuration with Drush
  • Commit it to Git
  • Push it to the remote repo
  • Pull it to production
  • Import the configuration to the production server
  • And have an exact replica of our development configuration on our production server!

When all of that is done, our two sites should have identical configuration (except that which is overridden in the settings.local.php files.)

Install Pathauto

composer require "drupal/pathauto:^1.0"

Install Devel

composer require --dev "drupal/devel:^1.0"

Notice I'm passing the "--dev" flag so that it goes to the "require-dev" section in composer.json.

Install Zymphonies Drupal 8 Theme

composer require "drupal/drupal8_zymphonies_theme:^1.0"

Enable Admin Toolbar, Admin Toolbar Extra Tools, Pathauto Devel and Devel Generate

drush en admin_toolbar admin_toolbar_tools pathauto devel devel_generate -y

Enable Drupal8 Zymphonies Theme as the Default Theme

  • Go to "Appearance" (admin/appearance)
  • Click "Install and set default" next to the Drupal8 Zymphonies Theme
  • Go "Back to site" to see the new theme

Change the Temporary File Path

  • Go to "Configuration => Media => File system" (/admin/config/media/file-system)
  • Change "Temporary directory" to "/tmp"
  • Save Configuration

Create View of Articles

Let's create a quick view of Articles and see how content can be pushed between sites.

Use Devel Generate

I'll create a bunch of test articles on development and a couple on production before I create the view.

Create the View

  • Go to "/admin/structure/views/add"
  • Name: Articles
  • Show: Content
  • of type: Article
  • [x] Create a page
  • [x] Create a block

We'll leave that alone now, and come back to it after we push config to our staging site.

Add Some Blocks to Various Regions

  • Go to "Structure => Block layout"
  • Place the "Articles" and "Who's new" blocks in the Left Sidebar
  • Save Blocks
  • Go "Back to site" to verify the blocks are in the right places

Save Google Analytics account to Configuration

  • Go to "Configuration => System => Google Analytics" (/admin/config/system/google-analytics)
  • Enter a Web Property ID (UA-99999999-99)
  • Save configuration

Override GA Account with Empty String in settings.local.php

  • Edit settings.local.php
  • Replace Google Analytics section with the following:
$config['google_analytics.settings']['account'] = "";

The empty quotes will prevent the development site from reporting to Google Analytics

Export Configuration with Drush

drush cex

You'll see a list of new and updated configuration.

  • Type "y" and press "Enter" to update the config files in your "config" directory.

Commit and Push Configuration with Git

git status
git add .
git status
git commit -m "Installed modules and themes. Exported config."
git push