Configuration values come from two places: appconfig.php (a file on disk) and the database (rows in .config). Knowing which source wins for which kind of setting prevents surprises.
appconfig.php
- A PHP file deployed alongside the application.
- Edited by developers; changes go through git.
- Best for: database credentials, encryption keys, environment-specific URLs, anything that's a deployment concern.
- Restart not always required, but cache may need clearing.
Database (.config table)
- Rows in the
.configdatastore. - Edited by administrators in the Site Settings UI.
- Best for: business-tweakable values — email templates, branding, password policy thresholds.
- Changes take effect immediately (or on next cache invalidation).
Resolution Order
- Database value (if present for the current scope: user → group → tenant → global).
- appconfig.php value.
- Code-level default.
Best Practices
- Keep secrets out of the database.
appconfig.phpis the right place. - Keep environment-specific values out of the database.
appconfig.phpper environment. - Keep all business-tweakable values in the database so non-developers can change them.
- Document each setting's preferred source.
Worked Examples
- Stripe secret key: appconfig.php — sensitive, environment-specific.
- Maximum login attempts: Database — admins tune this without redeploying.
- Brand colour: Database — designer changes via the UI.
- Database connection string: appconfig.php — environment-specific.
- Welcome email template: Database — marketing edits the wording.