Programmatically install Drupal 8 module

Submitted by timmillwood on Tue, 16/05/2017 - 07:41

There are times, often in tests or upgrade paths, where we want to programmatically install a module. Here's how:



This code can go pretty much anywhere. My most recent use for it was in a test where I wanted to add some content, then install a module, and test how the module reacted to the content which was there before the module was installed. For this I just added the code in the test method of a functional browser test.

Add new comment