Skip to content

Instantly share code, notes, and snippets.

@webflo
Created February 9, 2018 16:35
Show Gist options
  • Save webflo/00ce5131a37ae1ff83ca28760f1ce850 to your computer and use it in GitHub Desktop.
Save webflo/00ce5131a37ae1ff83ca28760f1ce850 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Local development override configuration feature.
*
* To activate this feature, copy and rename it such that its path plus
* filename is 'sites/default/settings.local.php'. Then, go to the bottom of
* 'sites/default/settings.php' and uncomment the commented lines that mention
* 'settings.local.php'.
*
* If you are using a site name in the path, such as 'sites/example.com', copy
* this file to 'sites/example.com/settings.local.php', and uncomment the lines
* at the bottom of 'sites/example.com/settings.php'.
*/
/**
* Load environment specific override configuration, if available.
*
* Keep this code block at the beginning of this file to take full effect.
*/
$dotenv = new Dotenv\Dotenv(dirname($app_root));
$dotenv->load();
$dotenv->required('MYSQL_DATABASE')->notEmpty();
$dotenv->required('MYSQL_HOSTNAME')->notEmpty();
$dotenv->required('MYSQL_PASSWORD');
$dotenv->required('MYSQL_PORT')->notEmpty();
$dotenv->required('MYSQL_USER')->notEmpty();
/**
* Database settings.
*/
$databases['default']['default'] = [
'database' => getenv('MYSQL_DATABASE'),
'driver' => 'mysql',
'host' => getenv('MYSQL_HOSTNAME'),
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'password' => getenv('MYSQL_PASSWORD'),
'port' => getenv('MYSQL_PORT'),
'prefix' => '',
'username' => getenv('MYSQL_USER'),
];
/**
* Include environment specific override configuration file, if available.
*
* Use settings.env.<ENV>.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing emails, and
* other things that should not happen on development and testing sites.
*/
$environment = getenv('DRUPAL_ENV');
if ($environment && file_exists($app_root . '/' . $site_path . '/settings.env.' . $environment . '.php')) {
require_once $app_root . '/' . $site_path . '/settings.env.' . $environment . '.php';
}
/**
* Override site mail.
*/
if (getenv('DRUPAL_SITE_MAIL')) {
$config['system.site']['mail'] = getenv('DRUPAL_SITE_MAIL');
}
/**
* Override temporary path.
*/
if (getenv('DRUPAL_PATH_TEMP')) {
$config['system.file']['path']['temporary'] = getenv('DRUPAL_PATH_TEMP');
}
/**
* Stage file proxy.
*/
if (getenv('DRUPAL_STAGE_FILE_PROXY_ORIGIN')) {
$config['stage_file_proxy.settings']['origin'] = getenv('DRUPAL_STAGE_FILE_PROXY_ORIGIN');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment