Information for: DEVELOPERS   PARTNERS

Acquia Lightning sub-profiles

Acquia Lightning allows you to create sub-profiles that are based on the default Acquia 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 Acquia Lightning would be of benefit include the following situations:

  • You want to prevent the installation of an Acquia Lightning component or sub-component.
  • 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 Acquia Lightning.
  • You previously used lightning.extend.yml to accomplish any of the previously items.

Creating a sub-profile

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

Generating a new Acquia Lightning sub-profile

For uncomplicated use cases, such as excluding some Acquia 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:

  • Drupal Console
  • Acquia Lightning version 2.0.4 or greater
  • An installed instance of Acquia 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 directory:

drupal lightning:subprofile

Converting lightning.extend.yml to a sub-profile

If you previously used the Acquia 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
  • Acquia Lightning version 2.0.4 and greater
  • An installed instance of Acquia Lightning or Drupal

Running the conversion

To convert the file, run the following command from your installation’s docroot directory:

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

Switching an existing Acquia Lightning install profile to a sub-profile

To switch an existing site’s install profile from Acquia 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 Acquia Lightning prior to version 8.x-2.0.5 included the lightning.extend.yml file, and installed modules in the following order:

  • core modules
  • Acquia Lightning modules
  • extend modules

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

As of version 2.0.5, Acquia Lightning defers to the core install system to determine when to install modules. With this change, you can’t rely on Acquia Lightning to install all modules by the time you install all your additional dependencies. By design, Acquia 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 dependencies 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]);
}