dev_env
Categories
Component ID
2110755
Component name
dev_env
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Adds module enabling per machine environment to the env project.
Preamble
A great feature of the env project is that you can set your $conf variable per machine that your site is running on . That is great for variables but I wanted it for modules as well - so dev_env does that.
Features
- Customized drupal configuration settings per machine environment
- Module enabling and disabling per environment
Module Enabling
To enable modules for a particular machine environment that is loaded via the env module add a modules_on array to your $conf settings variable. There is an example example.inc file that has the exact syntax. The modules in this array will be enabled during the hook_init phase of the module. Likewise to turn modules off - stick the array list in the modules_off $conf array.
Example settings
$conf = array(
'drupal_stale_file_threshold' => 172800 ,
'GoogleAnalytics' => FALSE,
'Qualtrics' => FALSE,
'Dev_AddThis' => FALSE,
'modules_on' => array(
'devel',
'bulk_export',
'update',
'views_ui',
'show_mobile',
),
'modules_off' => array(
'shield',
'ga_remarketing',
'omniture',
'varnish',
'memcache'
),
);
Dependencies
- This module runs independently of the env module
- I am very grateful for that module and have used his class and modified it slightly to suite my needs.
Installation
- Much like the env module you have to add this snippet of code to the end of your settings.php file.
// Required for Env module $dev_env = __DIR__ . '../all/modules/contrib/dev_env/includes/environments.inc'; if (file_exists($dev_env)) { require ($dev_env); } - Make sure that the path to your environments.inc file is correct. Some sites don't put their contrib modules in a contrib subdir of the modules directory. If you do not have the contrib subdir then do not put it in the $dev_env variable above.
- In your environment (server) do the following (following code assumes your environment is called "dev"):
-
In your virtualhost declare a server variable, e.g. for Apache:
SetEnv DRUPAL_ENV_NAME dev
If you need command-line tools like Drush to pick-up proper configuration, in your .profile or .bash_rc or .bash_profile script put the following:
export DRUPAL_ENV_NAME="dev"
-
In your virtualhost declare a server variable, e.g. for Apache:
- Create a sites/all/modules/contrib/dev_env/includes/dev.inc file and override any settings you need to override for that environment, previously set by settings.php. Most probably it will be MySQL connection properties, but could be many other things.
Put all shared configuration in settings.php, override environment-specific variations in an environment-specific file like dev.inc
