Skip to content

Instantly share code, notes, and snippets.

@japerry
Created September 11, 2017 22:23
Show Gist options
  • Save japerry/5d8356a4faab8c4f139ef8205becfde6 to your computer and use it in GitHub Desktop.
Save japerry/5d8356a4faab8c4f139ef8205becfde6 to your computer and use it in GitHub Desktop.
Example multisite local settings file.
<?php
/**
* @file
* Local development override configuration feature.
*/
use Symfony\Component\Yaml\Yaml;
if (file_exists($dir . '/blt/project.yml')) {
$project = Yaml::parse(file_get_contents($dir . '/blt/project.yml'));
//$request = \Drupal::hasRequest() ? \Drupal::request() : \Symfony\Component\HttpFoundation\Request::createFromGlobals();
//$role = basename(\Drupal\Core\DrupalKernel::findSitePath($request));
$name = substr($_SERVER['HTTP_HOST'],0, strpos($_SERVER['HTTP_HOST'],'.local'));
if (isset($project['project']['acsf'])
&& !empty($project['multisites'])
&& array_key_exists($name, $project['multisites'])) {
// The DB role will be the same as the gardens site directory name.
/**
* Database configuration.
*/
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => "drupal_{$name}",
'username' => 'drupal',
'password' => 'drupal',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
'prefix' => '',
),
),
);
$config_directories['sync'] = $dir . '/config/' . $name . '/local';
/**
* Private file path.
*/
$settings['file_private_path'] = $dir . "/files-private/${name}";
/**
* Public file path.
*/
// Set public filesystem per local development site.
$settings['file_public_path'] = "sites/default/files/${name}";
}
}
else {
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => 'drupal',
'username' => 'drupal',
'password' => 'drupal',
'host' => 'localhost',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
'prefix' => '',
),
),
);
$config_directories['sync'] = $dir . '/config/default';
// Set private filesystem for local development.
$settings['file_private_path'] = $dir . "/files-private/default";
}
// Use development service parameters.
$settings['container_yamls'][] = $dir . '/docroot/sites/development.services.yml';
// Allow access to update.php.
$settings['update_free_access'] = TRUE;
/**
* Assertions.
*
* The Drupal project primarily uses runtime assertions to enforce the
* expectations of the API by failing when incorrect calls are made by code
* under development.
*
* @see http://php.net/assert
* @see https://www.drupal.org/node/2492225
*
* If you are using PHP 7.0 it is strongly recommended that you set
* zend.assertions=1 in the PHP.ini file (It cannot be changed from .htaccess
* or runtime) on development machines and to 0 in production.
*
* @see https://wiki.php.net/rfc/expectations
*/
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
/**
* Show all error messages, with backtrace information.
*
* In case the error level could not be fetched from the database, as for
* example the database connection failed, we rely only on this value.
*/
$config['system.logging']['error_level'] = 'verbose';
/**
* Disable CSS and JS aggregation.
*/
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
/**
* Disable the render cache (this includes the page cache).
*
* Note: you should test with the render cache enabled, to ensure the correct
* cacheability metadata is present. However, in the early stages of
* development, you may want to disable it.
*
* This setting disables the render cache by using the Null cache back-end
* defined by the development.services.yml file above.
*
* Do not use this setting until after the site is installed.
*/
# $settings['cache']['bins']['render'] = 'cache.backend.null';
/**
* Disable Dynamic Page Cache.
*
* Note: you should test with Dynamic Page Cache enabled, to ensure the correct
* cacheability metadata is present (and hence the expected behavior). However,
* in the early stages of development, you may want to disable it.
*/
# $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
/**
* Allow test modules and themes to be installed.
*
* Drupal ignores test modules and themes by default for performance reasons.
* During development it can be useful to install test extensions for debugging
* purposes.
*/
$settings['extension_discovery_scan_tests'] = FALSE;
/**
* Enable access to rebuild.php.
*
* This setting can be enabled to allow Drupal's php and database cached
* storage to be cleared via the rebuild.php page. Access to this page can also
* be gained by generating a query string from rebuild_token_calculator.sh and
* using these parameters in a request to rebuild.php.
*/
$settings['rebuild_access'] = FALSE;
/**
* Temporary file path:
*
* A local file system path where temporary files will be stored. This
* directory should not be accessible over the web.
*
* Note: Caches need to be cleared when this value is changed.
*
* See https://www.drupal.org/node/1928898 for more information
* about global configuration override.
*/
$config['system.file']['path']['temporary'] = '/tmp';
/**
* Trusted host configuration.
*
* See full description in default.settings.php.
*/
$settings['trusted_host_patterns'] = array(
'^.+$',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment