Creates a drush command line interface for setting an environment for a site instance. Other modules may then change their logic depending upon the current active environment. The drush env-switch
command also invokes a hook to allow each module to run additional required actions when switching environments.
The environment states are completely customizable and may be arbitrarily set to any value that makes sense for the project at hand. The recommended set of environment states are 'development', 'production', and 'readonly'.
NOTE: This module has no UI, and merely provides a simple helper to allow modules to invoke actions when switching environments. A user interface is completely possible for certain use cases. I will accept patches if anyone wants to provide them.
Example
The following code snippet will disable developer modules when switching into production mode, and reenable them when switching back into development mode.
/**
* Implements hook_environment_switch().
*/
function YOUR_MODULE_environment_switch($target_env, $current_env) {
// Declare each optional development-related module
$devel_modules = array(
'bulk_export',
'context_ui',
'devel',
'devel_generate',
'devel_node_access',
'imagecache_ui',
'update',
'spaces_ui',
'views_ui',
);
switch ($target_env) {
case 'production':
module_disable($devel_modules);
drupal_set_message('Disabled development modules');
return;
case 'development':
module_enable($devel_modules);
drupal_set_message('Enabled development modules');
return;
}
}
You would then switch environments by using drush env-switch development
or drush env-switch production
in the command line.
This is also extremely handy for managing permissions when combined with features.
Note:
The user ceardach is no longer available. Please contact arknoll or Grayside if you need assistance.
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Developer Tools
- 561 sites report using this module
- Created by ceardach on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 7.x-1.x-dev updated 5 Jun 2015 at 13:33 UTC