Skip to main content

Settings

Settings are application-wide key/value values.

They exist for values that should be stored in the database instead of code or .env.

Use preferences instead when the value belongs to one user.

qore()->settings()->setSetting('invoice_prefix', 'INV');

$prefix = qore()->settings()->getSetting('invoice_prefix', 'INV');

Use getSettingOrFail() when missing configuration should stop execution.

Sensitive values

Encrypt credentials and other sensitive values before storing them, and decrypt them only when they are used:

qore()->settings()->setSetting('service.api_key', encrypt($apiKey));

$apiKey = decrypt(qore()->settings()->getSettingOrFail('service.api_key'));

getSetting() and getSettingOrFail() return the stored value as-is, so they do not decrypt encrypted settings automatically.