Sometimes a project moves in different directions despite it's intended origins, in this article we're not going to discuss when to use Acquia Lightning, as there are many instances when this may well be the best approach, but we are going to discuss how to remove Acquia Lightning should your project decide to take a different fork in the path, so to speak.
Before we can begin, however, we need to ensure that your Acquia Lightning project meets the following criteria:
- Your project must have been created via composer.
- Your version of Acquia Lightning must be 3 or higher, earlier versions of Acquia don't allow for using the modules separately.
- You have Drush installed to issue the commands provided.
If the criteria above have been met, then we can proceed, but first a disclaimer. Always ensure that you are running this on a test environment with a backup fully in place before any deployments to production, use cases and scenarios may vary, so take this into consideration that your own investigation may need to be conducted in order to get things just right.
First, we need to remove Lightning as the install profile and set Standard as the install profile, we'll also need to remove Lightning and Lightning Installer as active modules from the config:
drush config:set core.extension profile standard
drush config:delete core.extension module.lightning
drush config:delete core.extension module.lightning_install drush cr -y
What we've done above is modified our config before any major lifts and changes, this will prevent missing profile and module errors later on. We're basically removing the Lightning profile and the install helper. If we don't do this before everything else, we're going to run into some very annoying errors related to missing profiles and modules. So make sure this step is done first.
Next, you'll need to figure out which modules you are (or aren't) using, in our situation we were using the majority of the Lightning modules, including some of the media modules. The modules provided by Lightning contain a lot of sub-modules, so if you are using perhaps only a sub-module of media, you'll still need to require media. Be sure to do your own checks to see which sub-modules are contained in which module before making a decision about what not to include. The main ones provided by Lightning are Lightning API, Lightning Layout, Lightning Media and Lightning Workflow:
# Require Lightning modules and additional dependencies.
composer require drupal/panels:^4.4 --no-update
composer require drupal/lightning_api:^4.5 --no-update
composer require drupal/lightning_layout:^2.5 --no-update
composer require drupal/lightning_media:^3.16 --no-update
composer require drupal/lightning_workflow:^3.14 --no-update
The above ensures that after we remove lightning, we'll still have the modules that were using in place, you may find you do not need all of these, panels was a dependency that was carried over. Also, make sure that the versions you are requiring match the ones in your current Lightning installation:
# Remove Lightning.
composer remove acquia/lightning --no-update
# Add Core (We use the same version that Lightning is currently using).
composer require drupal/core:^8.8.5 --no-update
# Update composer.
We're not quite done yet, if we try to run a drush updb command or drush cr we're going to get a missing Lightning install error, so we'll need to drop into a MySQL session to remove the remnants of the Lightning and Lightning Install system schema from the key_val table. Execute the following MySQL statements:
DELETE from key_value WHERE collection = 'system.schema' AND name = 'lightning';
DELETE from key_value WHERE collection = 'system.schema' AND name = 'lightning_install';
Once that's been done, go ahead and run a drush cr command followed by a drush updb command. If you have any pending updates you should be able to see them run without being impeded by Lightning.
Now visit your local install, you should find things work correctly.
Finally, if everything works out, run a drush cex command to export and update all of our new config. Commit this to your git branch.
To deploy your newly committed work to a remote test environment, and eventually prod, follow the same steps above, minus the composer commands. Composer would have already been taken care of in your commit, along with the new config changes. You will do the following:
# We still need to manually update the config, despite committing our
# config changes, or else we'll run into a missing Lightning distribution
drush config:set core.extension profile standard -y
drush config:delete core.extension module.lightning
drush config:delete core.extension module.lightning_install
# SKIP ALL COMPOSER STEPS
# Run these MySQL Commands.
# DELETE from key_value WHERE collection = 'system.schema' AND name = 'lightning';
# DELETE from key_value WHERE collection = 'system.schema' AND name = 'lightning_install';
# Import our new config and run updates.
drush cim -y
drush updb -y
A word of note, you may find some additional dependencies need to be carried over, or specific versions. When we ran this originally, we had the dev version of the Page Manager module required in our composer.json file, this caused a white screen issue when trying to authenticate. Upon closer inspection of the Lightning distributions dependencies, we found that it was using the beta version of the Page Manager module, using this fixed our issue.
So when in doubt, check your own dependencies or any possible errors you encounter against Lightnings dependencies by visiting the GitHub repo and scanning the various makefiles and composer.json file.
I hope this article can help you with your project. Feel free to contact us if you need any help.