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 static
class 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
Config
values for core classes or modules
This would typically be done in mysite/_config.php
Config::inst()->update('Director', 'environment_type', 'dev');
Updating the
Config
in PHP should be avoided where possible as it's slower than using the cached values