Drupal8 installation profiles and distributions - notes

The installation profile is optional during the installation.
If a installation profile is marked as distribution then it is always run during the installation.

example installation profile https://github.com/rakeshjames/example_profile

How to create an install profile.

http://www.thecarneyeffect.co.uk/creating-installation-profile
https://github.com/drupal-cod/cod_kickstart

Simple use case: 
If the site is installed with install profile 'innovation' then media module is enabled and content type 'project' is created.

Steps:
a) source site
1. Install Drupal8 (source_d8)
2. Enable media module
3. Create a content type called 'project'
4. Export all the configuration - drush cex
If you installed Drupal8 via composer-template then the configuration files are here.
yourinstall/config/sync/install

b) target site:
1. Install Drupal8 (target_d8)

2. Create a profile using drupal console (if necessary)
target_d8 > drupal generate:profile  \
--profile="Innovation"  \
--machine-name="innovation"  \
--description="Innovation Profile"  \
--core="8.x"  \
--dependencies="media"
This should have created the profile 'innovation'
target_d8/web/profiles/innovation

3. Copy all of the modules and themes listed within core.extension.yml into your profile's info file (using the new info file's format).
( or) simply you can copy all the modules and themes from standard.info.yml to innovation.info.yml. If you do this way then dont forget to add 'media' in 'dependencies' section. Because we want to enable media module when this profile is installed as per our use case.

4. Copy all the config files from source_d8/config/sync/install to install folder of the profile target_d8/web/profiles/innovation/config/install

5.  In the config/install folder that contains the settings files you just copied over, delete the following files:
core.extension.yml
file.settings.yml
update.settings.yml

6. Remove all of the UUIDs and default_config_hash from your config files so that they don't conflict with those of new sites. This can be done quite easily on the command line like so all on one line:

target_d8/web/profiles/innovation > find config/install/ -type f -exec sed -i '' '/^uuid: /d' {} \;
target_d8/web/profiles/innovation > find config/install/ -type f -exec sed -i '' '/_core:/{N;d;}' {} \;

The installation profile is ready.

How to test:
Remove settings.php of target_d8 and delete the database.
Install target_d8 again with profile 'innovation' selected.
You should see media module enabled and content type 'project exists'




Comments

Popular posts from this blog

Programatically create layout builder section in Drupal

Code quality analysis of Drupal. Can I use Sonar?

Set up Drupal7 to Drupal8 migration in simple steps (using Drush)