Last active
April 24, 2019 04:13
-
-
Save simesy/9a628655983ea42c34b321f705b0990b to your computer and use it in GitHub Desktop.
Drupal 8 - Example settings.php setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See https://lilengine.co/articles/example-settings-php-drupal-8 | |
File structure in sites/default/... | |
- settings.php | |
- includes/ | |
--- default.settings.php | |
--- default.services.yml | |
--- lando.settings.php | |
--- lando.services.yml | |
--- local.settings.php (optional, not in Git) | |
--- local.service.yml (optional, not in Git) | |
--- platform.settings.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sites/default/includes/default.services.yml | |
# Set service parameters that are default regardless of hosting environment. | |
# Example below is just for example, but should work fine. | |
parameters: | |
session.storage.options: | |
gc_probability: 1 | |
gc_divisor: 100 | |
gc_maxlifetime: 200000 | |
cookie_lifetime: 2000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// sites/default/includes/default.settings.php | |
/** | |
* @file | |
* Set stuff that will be the same for the application under any | |
* circumstances, or just sensible defaults. | |
*/ | |
$settings['update_free_access'] = FALSE; | |
$settings['file_private_path'] = './sites/default/files/private'; | |
$settings['file_scan_ignore_directories'] = ['node_modules', 'bower_components',]; | |
$settings['hash_salt'] = 'G2RezNogY0QIilvW4Ysg0X2BjmXtMUsLPxrQxy1bUmoWYKKIArIYqvbsGw852WKQIE-6g4GlNA'; | |
$settings['container_yamls'][] = $app_root . '/sites/default/includes/default.services.yml'; | |
$config_directories[CONFIG_SYNC_DIRECTORY] = '../config/sync'; | |
// Detect hosting environment and load appropriately. | |
if (getenv('PLATFORM_RELATIONSHIPS')) { | |
// We are on the Platform.sh | |
include $app_root . '/sites/default/includes/platformsh.settings.php'; | |
} | |
else { | |
// We are developing locally. | |
include $app_root . '/sites/default/includes/lando.settings.php'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sites/default/includes/lando.services.yml | |
# Set default development parameters. | |
# Use local.services.yml to override. | |
parameters: | |
http.response.debug_cacheability_headers: true | |
twig.config: | |
debug: true | |
auto_reload: true | |
cache: false | |
services: | |
cache.backend.null: | |
class: Drupal\Core\Cache\NullBackendFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// sites/default/includes/lando.settings.php | |
/** | |
* @file | |
* This will be included from default.settings.php if we don't detect Platform.sh. | |
* It sets a lot of development defaults. | |
*/ | |
// This will be the same for all local dev, based on our standard Lando config. | |
$databases['default']['default'] = array ( | |
'database' => 'drupal8', | |
'username' => 'drupal8', | |
'password' => 'drupal8', | |
'prefix' => '', | |
'host' => 'database', | |
'port' => '3306', | |
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', | |
'driver' => 'mysql', | |
); | |
// Debugging, caching, etc. | |
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/includes/lando.services.yml'; | |
$settings['cache']['bins']['render'] = 'cache.backend.null'; | |
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; | |
$settings['cache']['bins']['page'] = 'cache.backend.null'; | |
$settings['twig_debug'] = TRUE; | |
$config['system.performance']['css']['preprocess'] = FALSE; | |
$config['system.performance']['js']['preprocess'] = FALSE; | |
$config['system.logging']['error_level'] = 'verbose'; | |
error_reporting(E_ALL); | |
ini_set('display_errors', TRUE); | |
ini_set('display_startup_errors', TRUE); | |
$settings['update_free_access'] = FALSE; | |
$settings['rebuild_access'] = TRUE; | |
$settings['skip_permissions_hardening'] = TRUE; | |
$config['system.logging']['error_level'] = 'verbose'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// sites/default/includes/platform.settings.php | |
/** | |
* @file | |
* A pretty minimal Platform.sh settings file. | |
* You can also set a platform.services.yml here, following same technique used in other files. | |
*/ | |
if (isset($_ENV['PLATFORM_APP_DIR'])) { | |
$relationships = getenv('PLATFORM_RELATIONSHIPS'); | |
$relationships = json_decode(base64_decode($relationships), true); | |
foreach ($relationships['database'] as $endpoint) { | |
if (empty($endpoint['query']['is_master'])) { | |
continue; | |
} | |
$databases['default']['default'] = array( | |
'driver' => $endpoint['scheme'], | |
'database' => $endpoint['path'], | |
'username' => $endpoint['username'], | |
'password' => $endpoint['password'], | |
'host' => $endpoint['host'], | |
'port' => $endpoint['port'], | |
'prefix' => '', | |
); | |
} | |
// Set appropriate hosts for Platform.sh. | |
$settings['trusted_host_patterns'] = [ | |
'^.+ab1cd3dc345s\.au\.platformsh\.site$', | |
'^lilengine\.co', | |
'^www\.lilengine\.co', | |
'^something-else\.lilengine\.co', | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// sites/default/settings.php | |
/** | |
* @file | |
* The file Drupal includes. Generally this file doesn't change because | |
* we include additional files. | |
*/ | |
$databases = []; | |
$config_directories = []; | |
// Default settings. All in git. | |
include $app_root . '/sites/default/includes/default.settings.php'; | |
// Totally *optional* local settings overrides that are not in git. | |
if (file_exists($app_root . '/sites/default/includes/local.settings.php')) { | |
include $app_root . '/sites/default/includes/local.settings.php'; | |
} | |
// Totally *optional* local services overrides that are not in git. | |
if (file_exists($app_root . '/sites/default/includes/local.services.yml')) { | |
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/includes/local.services.yml'; | |
} | |
// Put this last to prevent core trying to add it in some configurations. | |
$settings['install_profile'] = 'minimal'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment