Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

New Settings API added

Besides loading information from the {variable} table, variable_get() was frequently used to configure certain low-level (like swappable include files or page cache flags) or environment specific (like proxy or reverse proxy) configuration only through $conf in settings.php.

It is not possible or practical to move that configuration into the Drupal 8 configuration system because it is not available early enough and it is only possible to override existing configuration in settings.php with it.

A new, simple and read only settings API has been added that can be used for that kind of configuration. It can be accessed through \Drupal\Core\Site\Settings::get('my_setting') and can be set with $settings['my_setting'] in settings.php.

Additionally to configuration that used to be in $conf, additional global variables in settings.php are being moved to $settings, like $update_free_access.

It is recommended to document settings used by a module in a README.txt or similar place.

During the development of Drupal 8, settings()->get('my_setting') was used instead of Settings::get('my_setting'). This format is no longer supported.

Settings provided by core

Most of these settings are documented in settings.php and just need to be commented out and/or adjusted.

update_free_access # Previously a global variable $update_free_access
proxy_server
proxy_port
proxy_username
proxy_password
proxy_user_agent
proxy_exceptions
reverse_proxy
reverse_proxy_addresses
reverse_proxy_header
omit_vary_cookie
class_loader
allow_authorize_operations

maximum_replication_lag
page_cache_without_database
path_inc
session_inc
menu_inc

To test overriding settings in an automated test, you can use the settingsSet() method in Drupal\simpletest\TestBase.

$conf renamed to $config

Additionally to moving some of the settings to $settings, the global $conf variable is also renamed to $config. It now can override configuration in the Drupal 8 configuration system, so the Drupal 7 variable names are not useful anymore to use for overrides. To override the system site name:

// Drupal 7
global $conf;
$conf['site_name'] = 'Enforced site name';

// Drupal 8
global $config;
$config['system.site']['name'] = 'Enforced site name';
Impacts: 
Site builders, administrators, editors
Module developers