Why would you want to use a distribution? A distribution is a contributed installation profile that is not provided by Drupal core. Distributions provide a specialized version of Drupal with specific installed modules and themes along with specific configurations (content types, and blocks.) On Drupal.org, when you download an installation profile, it not only includes the profile and its modules but a version of Drupal core, hence the name distribution. You can find a list of all Drupal distributions at https://www.drupal.org/project/project_distribution.
Using a distribution with Drupal
How to do it...
We will follow these steps to download a distribution to use as a customized version of Drupal 8:
- Download a distribution from Drupal.org. For this recipe, let's use the Demo Framework provided by Acquia at https://www.drupal.org/project/df.
- Select the recommended version for the 8.x branch.
- Extract the folder contents to your web server's document root--you'll note that there is Drupal core; within the profiles folder, there's the installation profile's folder--df.
- Due to current Drupal.org packaging limitations, there is a manual step that you will need to run in order to install additional dependencies. Run the following command using your terminal inside of the extracted contents:
$ composer require "commerceguys/intl: ~0.7" "commerceguys/addressing: ~1.0" "commerceguys/zone: ~1.0" "embed/embed: ~2.2
- Install Drupal as you would normally, by navigating to your Drupal site in your browser.
- Follow the installation instructions in the site to install the distribution.
How it works...
Installation profiles work by including additional modules that are part of the contributed project realm or custom modules. The profile will then define them as dependencies to be installed with Drupal. When you select an installation profile, you are instructing Drupal to install a set of modules on installation.
Demo Framework declares itself as an exclusive installation profile. Distributions that declare this are automatically selected and assumed to be the default installation option. The exclusive flag was added with Drupal 7.22 to improve the experience of using a Drupal distribution (http://drupal.org/node/1961012).
There's more...
Distributions provide a specialized version of Drupal with specific feature sets, but there are a few items worth discussing.
Makefiles
The current standard for generating a built distribution is the utilization of Drush and makefiles. Makefiles allow a user to define a specific version of Drupal core and other projects (such as themes, modules, and third-party libraries) that will make up a Drupal code base. It is not a dependency management workflow, like Composer, but is a build tool.
If you take a look at the Demo Framework's profile folder, you will see drupal-org.make and drupal-org-core.make. These are parsed by the Drupal.org packager to compile the code base and package it as a .zip or .tar.gz, like the one you downloaded.
Installing with Drush
As discussed in the first recipe's There's more... section, you can install a Drupal site through the Drush command-line tool. You can instruct Drush to use a specific installation profile by providing it as the first argument.
The following command would install the Drupal 8 site using the Demo Framework:
$ cd /path/to/drupal8
$ drush pm-download df $ drush site-install df -db-url=mysql://user:pass@localhost/database
Using Composer
Currently, Drupal.org does not package distributions using Composer, which is why there was an extra step to add dependencies when installing the distribution. Many distributions provide project templates to make scaffolding projects simpler.
For example, the following command will set up a Demo Framework site with docroot as the directory for the web server document root, which contains Drupal 8:
$ composer create-project acquia/df-project df
The project template is available on Acqua's GitHub at https://github.com/acquia/df-project/.
Another distribution, Open Social, provides a template of its own:
$ composer create-project goalgorilla/social_template
The project template is available at https://github.com/goalgorilla/social_template.
See also...
- Refer to Chapter 13, The Drupal CLI, for information on makefiles.
- Refer to Distribution documentation on Drupal at https://www.drupal.org/documentation/build/distributions.
- Refer to Managing Your Drupal Project with Composer at https://glamanate.com/blog/managing-your-drupal-project-composer.
- Refer to Managing your Drupal platform with Drush at https://glamanate.com/blog/managing-your-drupal-platform-drush.