SilverStripe uses a global config system to store settings for classes and the application. These config variables can be used to define the structure of Models, security settings on Controllers or API keys for third party services.
Config values are populated by the SS_ConfigStaticManifest during a dev/build and cache flush (appending ?flush to any URL`) or on first ever run of the application code.
The SS_ConfigStaticManifest will scan all PHP classes and YAML config files for any config values and build a cache of these values.
When making change to
Configsettings via YAML orprivate staticvariables, you'll need to flush the cache for these changes to take effect.
Config values can be set in three ways:
private static variables on any class within a SilverStripe projectConfig::inst()->update('Director', 'environment_type', 'dev')Generally it's best to set config values via the first 2 methods as these are statically cached when flushing the cache.
class MyDataObject extends DataObject {
private static $db = array(
'Title' => 'Varchar',
);
}
All
private staticclass variables in a SilverStripe project's code (including modules, but not packages in thevendor/directory) will be loaded into theConfig.
You can add this to mysite/_config/config.yml (or any other YAML file in that path).
Director: environment_type: dev
Using YAML files is a great way to override default
Configvalues for core classes or modules
This would typically be done in mysite/_config.php
Config::inst()->update('Director', 'environment_type', 'dev');
Updating the
Configin PHP should be avoided where possible as it's slower than using the cached values