I am trying to enable modules by adding them to core.extension.yml file without getting involved with Features, Configuration Installer or similar modules or profiles. The modules are enabled but their default configuration under module_folder/config/install or module_folder/config/optional are not imported. Is there a way to do this?

  • 3
    So when exactly do you want to install a module? Installing a module through core.extension is perfectly valid if you're doing it as part of an config import. But then you have to provide all the configuration of the module also in the config sync folder. Usually you install the module somewhere on a test site, optionally customize the configuration, then export that, deploy it and import. You don't need features or anything like that. And you only need Config Installer if you try to install a completely new site through tat
    – Berdir
    Commented Aug 23, 2017 at 22:07
  • 1
    @Berdir thank you man, I was thinking that there is no one around here anymore after a few unanswered questions. Faith in Drupal Answers restored:) -- Since the projects I am doing is not that big and I am very lazy, I am not setting up clones for such testing purposes. But yes that's an ideal workflow. As of the Config Installer, I saw some issues in the queue and didn't wanna get involved with the module since it could give me more headache then manually installing 25 modules :)
    – duru
    Commented Aug 24, 2017 at 9:30
  • How do you solve your problem? Commented Sep 7, 2017 at 16:58
  • @AdrianCidAlmaguer hi, thanks for the follow up. I haven't tried any of them yet. I'll try in my next project and select an answer.
    – duru
    Commented Sep 8, 2017 at 15:02
  • @duru well just publish your solution, I think that this is a good question ;-) Commented Sep 8, 2017 at 15:46

2 Answers 2


This will not works because you are only saying to Drupal that your module is installed, but when you install a module there are other process that need to runs to import the configs and execute the .install functions.

But you can create a new module that will install all the other modules, create a .install file and add this inside:

 * Implements hook_install().
function MY_MODULE_install() {
  $modules_list = [

And then you only need to install this module that will install all the other modules.

  • @duru a pleasure help you, at the end lets us know which method you chose and why. Commented Aug 24, 2017 at 14:06
  • 1
    looks like @duru is still thinking about which answer to "chose" (= mark as accepted?) ... Commented Jan 22, 2018 at 21:37
  • 1
    Mind that hook_install will run on module installation only. If your module is already installed, use hook_update_N like CG Monroe answer.
    – wranvaud
    Commented Feb 4, 2021 at 18:07

A possible alternative would be use the dependencies section of a module's mymod.info.yml description. Enabling the module will enable the dependencies.

name: My Module
description: Provides something great
core: 8.x
type: module
  - views

If you need to make sure that certain modules are enabled due to code changes in an existing module, then use update system. E.g. add a hook_update_N function to the mymod.install file that calls the module.installer service.

 * Install file module.
function mymod_update_8001() {

FYI - Trying to install an installed module will not cause problems.

Trying to go outside the normal system by accessing the core.extensions is probably not a long term maintainable option.

  • Cool. Let's see if there will be other answers.
    – duru
    Commented Aug 24, 2017 at 9:33
  • 2
    @duru If you install as a dependency then can't uninstall any module because all are needed by your module (the module that install all the other modules), and if you use the hook_update() then you need to install the module and after run the update. This is why I think that is better put the code in the .install file, but it depends from your requirements. Commented Aug 24, 2017 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.