Keyboard

Shortcuts

Command palette
K
Home
gh
About
ga
Projects
gp
Expertise
gx
Journal
gj
Contact
gc
Copy email
e
Call
c
Toggle theme
t
Show this help
?

↑↓ to navigate · Enter to open · Esc to close

Architecture

Runtime config: why I moved SMTP and Gemini out of `.env`

TL;DR AppConfig + RuntimeConfigApplier. Empty secret field on save = keep the previous value.

12 Nov 2025 · Albert Nicolas

  • laravel
  • architecture
  • config
  • ops
Runtime config: why I moved SMTP and Gemini out of `.env`

1 min read Reading 0%

Changing the Gemini key or SMTP used to mean a redeploy. Absurd for a single-tenant portfolio I maintain myself. I switched to the Carnet de bord / news CMS pattern: options in admin, secrets encrypted at rest, merge at boot.

Clear boundary

In .env In admin (AppConfig)
APP_KEY, DB_* SMTP, from, contact notify
OWNER_EMAIL (login lock) Gemini / AI models
Rate limits, captcha, maintenance 503

The “empty keep existing” rule

if (blank($request->input('smtp_password'))) {
    unset($payload['smtp_password']); // do not overwrite
}

Without it, an honest admin save wipes the secret. I did it once. Once too many.

RuntimeConfigApplier

At boot, DB values are pushed into config('mail'), etc. Feature tests seed AppConfig — not only .env.testing. Otherwise tests pass locally and production lies.

← Back to journal

Contact me Call