Framework
Subsystems

Settings

Settings are typed values stored in the database and kept in sync with your config. You declare them once and read them through generated getters.

Declaring settings

Register each setting with a name, a section and a VariableType in a config file. The build generates a typed Setting class with a getter per entry:

config/Settings.config.php
use Framework\Core\SettingConfig;
use Framework\Core\VariableType;

SettingConfig::register("siteName", "General", VariableType::String);
SettingConfig::register("maxItems", "General", VariableType::Integer);
SettingConfig::register("features", "General", VariableType::List);

Grouping into sections

The second argument to register() is the setting's section — the group it belongs to. Sections don't change how a value is stored, but they shape the generated accessors and let you read or save a related batch together (a settings screen, say). The special General section is the default and stays unprefixed; every other section prefixes its accessors with the section name:

SettingConfig::register("siteName", "General", VariableType::String);
SettingConfig::register("fromName", "Email",   VariableType::String);
SettingConfig::register("fromMail", "Email",   VariableType::String);
use Framework\System\Setting;

Setting::getSiteName();       // General → no prefix
Setting::getEmailFromName();  // "Email" section → prefixed
Setting::setEmailFromMail("hi@app.com");

Each section also gets bulk helpers — getAll<Section>() and save<Section>() — so a whole group loads or persists at once:

Setting::getAllEmail();   // every Email setting as a map
Setting::saveEmail([
    "fromName" => "My App",
    "fromMail" => "hi@app.com",
]);

Variable types

The VariableType fixes how a value is stored and what type its getter returns:

TypeReturns
StringA string.
IntegerAn int.
FloatA float.
BooleanA bool (its getter is prefixed is).
ListA list<string>, stored as JSON.
ArrayAn associative array, stored as JSON.

Stored in the database

Settings live in a database table — one row per setting holding its section, variable, value and type. The value is encoded with the setting's VariableType on write and decoded on read. A migration keeps the table in sync with your config: new settings are added, changed ones updated and removed ones deleted, so the database always matches what you registered.

Reading & writing

The generated Setting class gives you a typed, autocompleted getter per setting:

use Framework\System\Setting;

Setting::getSiteName();   // "My App"  (string)
Setting::getMaxItems();   // 20        (int)
Setting::getFeatures();   // list<string>

Each setting also gets a matching set<Name>(), which encodes the value for its VariableType and persists it to the table, returning whether the write succeeded:

Setting::setSiteName("My New App");   // string
Setting::setMaxItems(50);             // int
Setting::setFeatures(["beta", "chat"]); // list<string>

To write several at once, use the generated per-section and global helpers — handy for saving a settings form. They take a variable => value map:

// Save one section, or everything, at once
Setting::saveGeneral([
    "siteName" => "My New App",
    "maxItems" => "50",
]);
Setting::saveAll($data);

// And read a whole section back
Setting::getAllGeneral();   // [ "siteName" => "My New App", … ]