1

I'm using a settings.local.php for my local development environment. This is a Drupal 7 site.

I've seen a few references to this via google search, but none of the examples are working for me. I don't want to install a module to make this work if it is possible to accomplish the same result by adding a couple lines to the settings.local.php file.

I use this file all the time for a number of sites so I know it is being read properly. I've also used it to set variables (file_temporary_path, for example) and that works too. It is just enabling / disabling modules I'm having trouble with.

Any thoughts / suggestions?

0

I don't know if it is possible to enable / disable modules in settings.local.php but for downloading and enabling modules you can use drush, like so:

drush dl views
drush en views -y

For disabling the modules use:

drush dis views -y

Another method is to implement hook_update() in a custom module's module file to disable / enable modules.

/**
* Uninstall views module.
*/
function MODULENAME_update_7000(&$sandbox) {
   module_disable(array('views'));
   drupal_uninstall_modules(array('views'), FALSE);
}

Of cource you can also use module_enable in the hook_update()

/**
* Install views module.
*/
function MODULENAME_update_7001(&$sandbox) {
   module_enable(array('views'));
}

If you use hook_update then remember to do:

drush updb 

and

drush cr

Hope this can help you.

0

I ended up using the Habitat module (https://www.drupal.org/project/habitat).

It has a UI that allows you to enter the names of modules you want turned off or on in each environment you have. Things like making sure Devel is ON in a local or DEV environment, and Views UI is OFF for a LIVE site.

It is simple to use and I haven't had any issues with it yet on the sites on which I have installed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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