Lightning sub-profiles

Lightning includes the ability to create sub-profiles that are based on the default Lightning distribution profile. Making a sub-profile allows you to customize the installation process to meet one or more of your specific needs.

If any of the following are true, you should create a sub-profile of Lightning:

  • You want to prevent some component or subcomponent of Lightning from being installed.
  • You want to enable additional modules, themes, or configuration during install.
  • You want to customize the look and feel of the installation process.
  • You want to build a distribution that offloads modules such as Media, Layout, and Workflow to Lightning.
  • You previously used lightning.extend.yml to accomplish any of the previous items.

Creating a sub-profile

Select from the following three primary methods to create a Lightning sub-profile:

Generating a new Lightning sub-profile

For simple use cases, such as wanting to exclude some of Lightning's components or include a few of your own, you can use the provided sub-profile generator.

Requirements

To run the sub-profile generator, the following items are required for your application:

  • DrupalConsole
  • Lightning version 2.0.4 and greater
  • An installed instance of Lightning or Drupal

Running the generator

After you have ensured that your application meets the previous requirements, run the following command from your installation's docroot:

drupal lightning:subprofile

Converting lightning.extend.yml to a sub-profile

If you have previously used the Lightning extend file (lightning.extend.yml), you can also convert the file to a sub-profile.

Requirements

To run the conversion, the following items are required for your application:

  • DrupalConsole
  • Lightning version 2.0.4 and greater
  • An installed instance of Lightning or Drupal

Running the conversion

To convert the subfile, run the following command from your installation's docroot:

./vendor/bin/lightning-subprofile /path/to/your/extend/file/lightning.extend.yml

Switching an existing site’s install profile from Lightning to a sub-profile

To do this, complete the following steps:

  1. Edit the settings.php.
  2. In the file, add or update the install_profile:

    $settings['install_profile'] = '[SUB-PROFILE_NAME]';
  3. Run the following command to enable the profile:

    drush cset core.extension module.[SUB-PROFILE_NAME] 0
  4. If you use CMI or have exported the core.extension.yml, export the updated extension listing to file.

Comparing sub-profiles and the lightning.extend.yml file

Versions of Lightning prior to 8.x-2.05 included the lightning.extend.yml file, and installed modules in the following order:

  • core modules
  • Lightning modules
  • extend modules

Extend modules were installed in the order that they were listed in the extend file.

As of version 2.05, Lightning defers to the core install system to determine when modules get installed. With this change, users cannot rely on all of Lightning's modules being installed by the time your additional dependencies are installed. By design, optional configurations are not installed until the end of the installation process. Any attempt to modify optional configurations should happen with hook_ENTITY_presave rather than hook_install or similar.

If this causes problems during your installation, one resolution method is to remove the dependencies from your subprofile.info.yml file, and then move them into an install hook in your sub-profile’s install file. For example:

$modules = [
    'mymodule',
    'foo',
    'bar',
    // ...
  ];

foreach ($modules as $module) {
    \Drupal::service('module_installer')->install([$module]);
}

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
By submitting this form, you accept the Mollom privacy policy.

Contact supportStill need assistance? Contact Acquia Support