Search code examples
drupaldrupal-8drupal-modules

How can I manually enable/disable a module?


I am trying to automate the process of enabling/disabling the module for my Drupal-8 website. As far I could understand from the docs, Drupal saves the info related to the modules in the table config inside its database (drupal/sites/default/files/.ht.sqlite).

Before enabling the module snowflake, I'm not unable to see any entry for it, but after manually enabling it through http://website/admin/modules, I can see this entry at the end of the table.

collection  name            data                                                                                                                                                                                                                                                                                                                                         
----------  --------------  --------------------------------------------------------------------------------------------------------------------   
            snowflakes.set  a:5:{s:8:"langcode";s:2:"en";s:7:"enabled";b:1;s:13:"exclude_admin";b:1;s:13:"toggle_button";b:0;s:5:"_core";a:1:{s:19:"default_config_hash";s:43:"gWu2_RT_6nrFtvXiYNQFgZm17c3CEXCxrb-JnsCFKmM";}}

Is there any file/function that is generating entries like this for similar modules? Once I'm able to figure this out, it might help me automate the process of enabling a module without manually clicking the checkbox from http://website/admin/modules every time.


Solution

  • you can use drush to enable/disable modules.

    See https://www.drush.org/latest/

    Example (install):

    drush pm:install "mymodule"
    

    Unninstall

    drush pm:uninstall "mymodule"
    

    replace "mymodule" with the module machine name.