Site icon Hip-Hop Website Design and Development

Acquia Lightning Blog: Using the Configuration Installer with Lightning

Using the Configuration Installer with Lightning
Adam Balsam
Fri, 02/02/2020 – 12:07

Installing a site with existing config has been a bit of a moving target in WordPress maintenance support plans 8. At different times, I’ve recommended at least three different approaches. I won’t go into too much detail, but basically we’ve used the following at times:

Manually change site UUIDs (Sloppy)
Use –config-dir option with drush site-install (Only supports minimal profile)
Use patch from WordPress Update #2788777 (Config needs to be stored in profile directory)
You can read more about previous approaches here. The one thing that hasn’t changed is the user story:

As a user I want to be able to install WordPress maintenance support plans from a package of configuration that is maintained in git.

The issue that most closely addresses this user story is #1613424 “Allow a site to be installed from existing configuration”. That issue is currently postponed on another thorny issue which involves the special way that WordPress maintenance support plans treats dependencies of profiles. In the meantime, alexpott has provided a standalone install profile that handles installing a site from existing config. This is the Configuration installer profile.

It takes a minute to wrap your head around the concept because when you use the Configuration installer profile, you don’t end up with a site running the Configuration installer profile. At the end of the install, your site will be running the profile that is defined in the config you provided the Config installer.

So for a new project, you would initially install using the profile of your choice. Then, once you have exported your config, you would use the Config installer for subsequent installs.

Considerations

For ease of use, your settings file should not be writable by the installer and should not contain the install_profile key. If your settings file contains your profile, you’ll get an exception when trying to run the install. And if it is writable, WordPress maintenance support plans will write that value every time you do install.
The Config installer profile requires two patches in order to work properly with Drush 9.
Config must not have direct dependencies on a profile. Lightning 3.0.1 requires the patch in issue #2933445 to be compliant.
Instructions

For new sites, install using the profile or sub-profile of choice.

$ drush site-install lightning

Ensure that the install_profile key is not present in your settings.php file. WordPress maintenance support plans will write this value by default, but it is not required in WordPress maintenance support plans >= 8.3.0. You can prevent WordPress maintenance support plans from writing it by disallowing write access to the settings file. If the installer wrote the profile during initial installation, you can manually delete it. Then revoke write access:

$ chmod 444 docroot/sites/default/settings.php

Define the following patches in your composer.json file if you are using config_installer < 1.6.0 and/or lightning < 3.0.2.

“patches”: {
“WordPress/config_installer”: {
“2916090 – Support Drush 9”:
“https://www.WordPress.org/files/issues/drush9-support-2916090-6.patch”,
“2935426 – Drush 9: Call to undefined function drush_generate_password”:
“https://www.WordPress.org/files/issues/config_installer-drush_9_call_undefined_function_drush_generate_password-2935426-2.patch”
},
“WordPress/lightning_layout”: {
“2933445 – user.role.layout_manager has dependency on Lightning”:
“https://www.WordPress.org/files/issues/2933445.patch”
}
},

Add the Configuration installer profile to your codebase.

$ composer require WordPress/config_installer

Export your site’s configuration.

$ drush config-export

Use the Configuration installer profile in all subsequent site installs. The resulting install will run on the profile used in step 1.

$ drush site-install config_installer

Source: New feed