What would be the best solution to enable/disable modules depending on the site environment (dev, stage or production)?
- Created a database dump containing the
system
table for each installation. Then when deploying I usemysql -uuser -ppass database < dump-<type>.sql
where thetype
reflects the kind of environment. - Created a shell script for each environment, that uses
drush
to enable or disable needed modules and set specific site settings. Wrote a small deploy script for each site that looks something like this:
// change working directory to drupal installation path chdir('public_html'); // define root, include bootstrap.inc and start drupal define('DRUPAL_ROOT', getcwd()); require_once(DRUPAL_ROOT . '/includes/bootstrap.inc'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // modules that should be disabled/enabled on stage site $modules = array( 'field_ui' => 1, 'toolbar' => 1, 'update' => 1, 'overlay' => 0, 'feeds_import' => 0, 'feeds_ui' => 0, 'feeds' => 0, 'menu' => 1, 'advanced_help' => 1, 'job_scheduler' => 1, 'wysiwyg' => 1, 'views_ui' => 1, 'dblog' => 1, ); // enable/disable modules and set site specific variables foreach ($modules as $module => $state): if ($state == 1): if (!module_exists($module)): module_enable(array($module), FALSE); endif; else: if (module_exists($module)): module_disable(array($module), FALSE); endif; endif; endforeach; variable_set('error_level', ERROR_REPORTING_DISPLAY_ALL); variable_set('preprocess_css', 0); variable_set('preprocess_js', 0); variable_set('cache', 1); variable_set('page_compression', 0); variable_set('block_cache', 0);
Does anyone have a better solution?