Environment & Secrets
Tune env variables for each stage (local, staging, production).
Quick reference #
| Key | Effect |
|---|---|
APP_ENV |
Informational environment label used by commands (e.g., migrate warns if set to production). |
APP_DEBUG |
Enables verbose exception output (HTML+JSON stack traces). Always false in production. |
APP_URL |
Base URL injected into theme variables and link helpers. |
APP_NAME |
Appears in templates, CLI greetings, and meta tags. |
DB_CONNECTION, DB_DATABASE, DB_HOST, DB_USERNAME, DB_PASSWORD |
Configure the active database connection as defined in config/db.php. |
CACHE_DRIVER, CACHE_PREFIX |
Select cache backend (file, redis, …) and namespace keys per deployment. |
CONTENT_DRIVER |
Choose file, db, hybrid, or auto for the page pipeline. |
THEME |
Overrides config/theme.php’s active value so tenants can pick different themes. |
SESSION_* |
Control cookie name, lifetime, SameSite/Secure flags (see config/session.php). |
REDIS_* |
Host, port, password for Redis-backed cache/session drivers. |
Cache & sessions #
CACHE_DRIVER:file(default) orredis. Provide Redis host/port/password viaREDIS_*env keys defined inconfig/cache.php.CACHE_PREFIX: differentiate multiple deployments sharing the same backend.SESSION_LIFETIME,SESSION_COOKIE,SESSION_SECURE_COOKIE: control session persistence + cookie flags.
Database #
Pick a connection via DB_CONNECTION (sqlite/mysql/pgsql). Each driver honors its own env keys (see config/db.php). CLI commands use the same connection object—the diagnose command will prove whether the credentials work.
Content pipeline #
CONTENT_DRIVERtoggles betweenfile,db,hybrid, orauto(switches based on page count).- Markdown caching inherits TTL from
content.markdown.cache_ttl; override withCONTENT_MARKDOWN_CACHE_TTLby adding it to.envand referencing viaenv()calls if needed.
Theme & modules #
THEMEpicks the folder underthemes/thatThemeServiceshould load. Great for per-tenant overrides.MODULE_PATHSisn’t an env var today, but you can extendconfig/modules.phpto read one if you need runtime reconfiguration.
Deployment tips #
- Keep secrets (
DB_PASSWORD, API tokens) out of Git; inject via your orchestrator. - After editing
.env, clear OPcache or restart PHP-FPM so the bootstrap sees new values. - Pair env changes with
./velvet config:cachein CI so the cached file matches the new values.
A disciplined .env strategy makes it trivial to run VelvetCMS locally, on staging, and in production without forking the codebase.