Environment Variables Reference

PhrameCMS skeleton applications derive all runtime configuration from environment variables parsed by App\EnvLoader and validated into an immutable App\AppConfig value object.

.env Loading & Parsing Semantics (App\EnvLoader)

Every entrypoint (public/index.php, bin/phrame, bin/phrame-mcp) calls App\EnvLoader::load($projectRoot . '/.env'):

  • Process environment wins: Real process environment variables (from systemd, Docker, Kubernetes, PHP-FPM env[...], or shell exports) are never overwritten by .env.
  • Missing .env is tolerated: If .env does not exist, EnvLoader::load() cleanly returns the process environment.
  • Supported syntax:
    • KEY=value and optional export KEY=value
    • Blank lines and # full-line comments, plus trailing # comments preceded by whitespace on unquoted values
    • Single-quoted ('...') literal values and double-quoted ("...") values supporting \n, \r, \t, \", and \\ escapes
  • Boolean parsing (AppConfig::parseBool()):
    • Truthy (case-insensitive): 1, true, yes, on
    • Falsy (case-insensitive): 0, false, no, off
    • Empty or unrecognized values fall back to the variable's default.

Application & MCP Runtime Variables

Verified against App\AppConfig, App\Mcp\StdioRunner, and .env.example:

Variable Default Valid Values Security & Operational Notes
PHRAME_DSN sqlite:<project-root>/var/phrame.sqlite SQLite (sqlite:var/phrame.sqlite, sqlite::memory:), PostgreSQL (pgsql://<user>:<pass>@<host>:5432/<db>), MariaDB/MySQL (mysql://<user>:<pass>@<host>:3306/<db>), or in-memory test driver (memory://) AppBootstrap::boot() automatically creates missing parent directories for file-based SQLite DSNs. Keep credentials out of Git; inject via secret manager or host environment in production.
PHRAME_CONFIG_SYNC_DIR <project-root>/config/sync Any non-empty filesystem path Directory used by config.export, config.import, and config.diff (FileConfigStorage). Track this directory in Git for declarative config-as-code workflows.
PHRAME_DEBUG 0 (false) Boolean (1/true/yes/on or 0/false/no/off) Enables detailed error diagnostics in RoutingModule and AdminModule. Must be 0 in production to avoid leaking stack traces or internal paths.
PHRAME_DISCOVER_COMPOSER_MODULES 1 (true) Boolean (1/true/yes/on or 0/false/no/off) Controls whether App\ModuleDiscovery scans vendor/composer/installed.json for packages declaring extra.phramecms.modules. Set to 0 to lock module loading strictly to built-in modules and config/modules.php.
PHRAME_ADMIN_SECURE_COOKIE 0 (false) Boolean (1/true/yes/on or 0/false/no/off) When enabled, forces the Secure flag on Admin UI phrame_session cookies (AdminModule::$secureCookie = true). Set to 1 in all HTTPS production deployments; keep 0 only for plain-HTTP local development.
PHRAME_ADMIN_TEMPLATES_DIR <project-root>/templates/admin (only if directory exists; otherwise null) Non-empty directory path Project-level Admin Twig template override root (checked ahead of the active theme and @admin_base, and checked at <dir>/modules/<namespace>/ for module namespaces).
PHRAME_ADMIN_ASSETS_DIR <project-root>/assets/admin (only if directory exists; otherwise null) Non-empty directory path Project-level Admin static asset override directory served under /admin/assets/.
PHRAME_MCP_AUDIT_DEFAULT_LIMIT 100 Positive integer (1–200) Default number of audit records returned by the phrame://audit/recent MCP resource. AppConfig requires >= 1, and AuditResourceProvider::MAX_LIMIT caps the limit at 200.
PHRAME_MCP_TOKEN (unset) Scoped AI Agent bearer token (for example, issued by ./bin/phrame site:install --issue-agent-token or agent_token.create) Read by App\Mcp\StdioRunner (./bin/phrame-mcp) when --token is not passed on the CLI. Treat as a secret: grant least-privilege scopes, never commit to .env.example or Git, and prefer env injection over --token CLI arguments.
PHRAME_HTTP_PORT 8080 Integer (1–65535) Local HTTP port used by docker-dev/compose.yaml and by AppConfig::resolvedBaseUrl() fallback (http://127.0.0.1:<PHRAME_HTTP_PORT>). Throws InvalidArgumentException if out of range.
PHRAME_BASE_URL http://127.0.0.1:<PHRAME_HTTP_PORT> Valid http:// or https:// URL with host (trailing slash trimmed automatically) Canonical public base URL used by CLI commands such as ./bin/phrame user:login (AppModule::$defaultBaseUrl). Set to your public HTTPS origin (for example, https://cms.example.test) in staging and production.

Local Docker Development Variables

Used exclusively by ./bin/dev and docker-dev/compose*.yaml in phramecms/skeleton (not read by AppConfig):

Variable Default Used By Purpose
PHRAME_UID Host id -u (via ./bin/dev), or 1000 docker-dev/compose.yaml Container user ID for the php service so var/ and config/sync/ match host file ownership.
PHRAME_GID Host id -g (via ./bin/dev), or 1000 docker-dev/compose.yaml Container group ID for the php service.
PHRAME_DB_NAME phrame compose.postgres.yaml, compose.mariadb.yaml Database name created in the local PostgreSQL or MariaDB container.
PHRAME_DB_USER phrame compose.postgres.yaml, compose.mariadb.yaml Database username created in the local PostgreSQL or MariaDB container.
PHRAME_DB_PASSWORD phrame_dev compose.postgres.yaml, compose.mariadb.yaml Database password for local Docker dev overlays only (never reuse in production).

Example Production Environment

dotenv
# Inject via your deployment platform or secret store; never commit real secrets to Git.
PHRAME_DSN="pgsql://<db-user>:<db-password>@db.internal:5432/phramecms"
PHRAME_CONFIG_SYNC_DIR=/srv/phrame/config/sync
PHRAME_DEBUG=0
PHRAME_DISCOVER_COMPOSER_MODULES=1
PHRAME_ADMIN_SECURE_COOKIE=1
PHRAME_BASE_URL=https://cms.example.test
PHRAME_MCP_AUDIT_DEFAULT_LIMIT=100

Security Checklist

  1. Never commit .env — keep .env in .gitignore and use .env.example strictly for documentation with empty secret placeholders.
  2. Disable debug mode in production — always set PHRAME_DEBUG=0 outside local development.
  3. Require secure Admin cookies over HTTPS — always set PHRAME_ADMIN_SECURE_COOKIE=1 behind TLS.
  4. Scope and protect PHRAME_MCP_TOKEN — issue dedicated least-privilege agent tokens per integration (avoid * in production) and pass them via environment variables rather than --token CLI flags.