Lightning sub-profiles

Lightning allows you to create sub-profiles that are based on the default Lightning distribution profile. Making a sub-profile enables you to customize the installation process to meet your specific needs.

Circumstances where creating a sub-profile of Lightning would be of benefit include the following situations:

  • You want to prevent the installation of a Lightning component or subcomponent.
  • 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 previously items.

Creating a sub-profile

To create a Lightning sub-profile, use one of the following methods:

Generating a new Lightning sub-profile

For simple use cases, such as excluding some Lightning components or including a few of your own, you can use the sub-profile generator.

Note

The generator is also a good starting point for more complex sub-profiles.

Requirements

To run the sub-profile generator, ensure that you have the following items for your application:

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

Running the generator

After you ensure 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 previously used the Lightning extend file (lightning.extend.yml), you can also convert the file to a sub-profile.

Requirements

To run the conversion, your application requires the following items:

  • 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 switch an existing site’s install profile from Lightning to a sub-profile, 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 a file.

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

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

  • core modules
  • Lightning modules
  • extend modules

These previous versions installed extend modules to list them in the extend file.

As of version 2.0.5, Lightning defers to the core install system to determine when to install modules. With this change, you can’t rely on Lightning to install all modules by the time you install all your additional dependencies. By design, Lightning does not install optional configurations until the end of the installation process. Any attempt to modify optional configurations must occur 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 those dependecies 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]);
}

Contact supportStill need assistance? Contact Acquia Support

Acquia: Think Ahead

53 State Street, 10th Floor
Boston, MA 02109
United States
Phone: 888-922-7842

Map: Google Maps
View other locations