Configuration
Environment values live in .env files and are read through the generated
Config class. The build turns every key into a typed method, so you never touch raw values at
runtime.
The .env file
Values live in a .env file at the project root, written as KEY = value pairs. The
framework ships a base .env.example that lists every supported key with a sensible default, so
your .env only needs the values you actually change:
NAME = "My App"
URL = "https://example.com/"
DB_DATABASE = "myapp"
DB_USERNAME = "root"
DB_PASSWORD = ""Every key becomes a typed method
During the build, each entry is turned into a typed getter on the generated
Config class. The name is converted from constant case and the return type is inferred from the
value — booleans get an is getter:
use Framework\System\Config;
Config::getName(); // "My App" (string)
Config::getDbLogTime(); // 3 (int)
Config::isAuthActive(); // true (bool)
URLs are special
Any key ending in URL becomes a path builder rather than a plain getter: it
appends the parts you pass onto the base url, so you never join paths by hand. A specific url key falls back to
the base URL when it is empty:
Config::getUrl(); // https://example.com/
Config::getUrl("api", "users"); // https://example.com/api/users
Config::getFileUrl("avatars", 7); // https://example.com/files/avatars/7
Environments
Next to .env you can add one file per environment: .env.local,
.env.production, .env.staging, and so on. The values in the matched file
overwrite the ones in .env, which in turn overwrite the framework's
.env.example defaults — so each layer only sets what it needs to change.
URL = "https://myapp.com/"
DB_HOST = "10.0.0.5"
DEBUG = falseThe right file is chosen automatically by matching the host of a *URL key against the host of
the current request. Point .env.production's URL at myapp.com and it
loads there.
The local environment
Local development uses the special local environment, which always exists. Add a
.env.local whose URL points at your local host and it loads while you develop,
overwriting .env like any other environment. When no file matches the current host you fall back
to local as well:
URL = "http://localhost:8080/"
DEBUG = trueEach environment also generates an is check — the local one is always present:
Config::isLocal(); // true while developing
Config::isProduction(); // true on myapp.com
Forcing an environment
On the command line there is no request URL to match — a deploy script, a migration, a cron. Set the
ENV_FILENAME environment variable to load a specific file regardless of host:
# deployment / CI
ENV_FILENAME=.env.production ./framework migrate
How the files are read
Configs is what turns those files into the generated class. It reads the
framework's .env.example first, then your .env, then the file matching the
environment — each layer overwriting the last, which is why a
.env.production only needs the values that differ.
use Framework\Core\Configs;
Configs::getEnvironment(); // the environment that matched
Configs::getEnvironments(); // every one that has a file
Configs::setFileName(".env.production"); // force one, before anything reads it
setFileName() is what migrate uses
for its env-file argument, and the same idea as the
ENV_FILENAME variable. During a
build this class is also the builder that writes
Config, so the typed getters and the files they read come from one place.
.env.example reference
Every key the framework understands, grouped by the sections of .env.example:
General
Application identity and the base url.
| Key | Description |
|---|---|
NAME | The application name. |
URL | The base url — used by getUrl() and for environment matching. |
Database
MySQLi connection, encryption key and slow-query logging. See Database.
| Key | Description |
|---|---|
DB_HOST | Database host. |
DB_PORT | Database port (default 3306). |
DB_DATABASE | Database name. |
DB_USERNAME | Database user. |
DB_PASSWORD | Database password. |
DB_CHARSET | Connection charset (default utf8mb4). |
DB_KEY | Key used to encrypt stored values. |
DB_LOG_TIME | Slow-query threshold, in seconds. |
DB_SCHEMA_FILE | Name of the file the build writes the schema JSON into. Empty skips it. |
File
Where uploaded files are stored and served from. See Files & Storage.
| Key | Description |
|---|---|
FILE_URL | Base url for served files. |
FILE_DIR | Directory that stores files (default files). |
FILE_FTP | Directory for FTP uploads. |
Auth
JWT signing, token lifetimes and API access. See Authentication.
| Key | Description |
|---|---|
AUTH_ACTIVE | Enables the Auth module. |
AUTH_KEY | Secret used to sign JWT tokens. |
AUTH_HOURS | Access-token lifetime, in hours. |
AUTH_DAYS | Refresh-token lifetime, in days. |
AUTH_FIELDS | Extra credential fields to expose. |
AUTH_API_TOKEN | Static token for server-to-server API access. |
Sending, templating, providers and cleanup. See Emails.
| Key | Description |
|---|---|
EMAIL_ACTIVE | Enables sending email. |
EMAIL_USE_WHITE_LIST | Restrict recipients to the white list. |
EMAIL_PROVIDER | Which transport to send through. |
EMAIL_NAME | Default "from" name. |
EMAIL_EMAIL | Default "from" address. |
EMAIL_REPLY_TO | Default reply-to address. |
EMAIL_URL | Base url used inside email links. |
EMAIL_TEMPLATE | Path to the HTML email template. |
EMAIL_LOGO | Path to the email logo image. |
EMAIL_LOGO_HEIGHT | Logo height, in pixels. |
EMAIL_LIMIT | Max emails per run (0 = no limit). |
EMAIL_RECAPTCHA_SECRET | reCAPTCHA secret for the contact form. |
EMAIL_DELETE_DAYS | Days to keep sent emails. |
SMTP
Credentials for the built-in SMTP transport. See Email providers.
| Key | Description |
|---|---|
SMTP_HOST | SMTP server host. |
SMTP_PORT | SMTP port. |
SMTP_SECURE | Encryption (ssl / tls). |
SMTP_USERNAME | SMTP user. |
SMTP_PASSWORD | SMTP password. |
SMTP_DEBUG | Verbose SMTP logging. |
Mailjet
Mailjet transport and default contact list. See Email providers.
| Key | Description |
|---|---|
MAILJET_KEY | Mailjet API key. |
MAILJET_SECRET | Mailjet API secret. |
MAILJET_LIST | Default contact list id. |
Mailgun
Mailgun transport key. See Email providers.
| Key | Description |
|---|---|
MAILGUN_KEY | Mailgun API key. |
Mandrill
Mandrill transport key. See Email providers.
| Key | Description |
|---|---|
MANDRILL_KEY | Mandrill API key. |
Send Grid
SendGrid transport key. See Email providers.
| Key | Description |
|---|---|
SEND_GRID_KEY | SendGrid API key. |
Mailchimp
Audience sync and campaign sending. See Email providers.
| Key | Description |
|---|---|
MAILCHIMP_ACTIVE | Enables the Mailchimp integration. |
MAILCHIMP_SUBSCRIBER_ACTIVE | Sync subscribers. |
MAILCHIMP_CREATE_ACTIVE | Allow creating contacts. |
MAILCHIMP_SEND_ACTIVE | Allow sending campaigns. |
MAILCHIMP_KEY | Mailchimp API key. |
MAILCHIMP_LIST | Audience / list id. |
MAILCHIMP_NAME | Default "from" name. |
MAILCHIMP_REPLY_TO | Default reply-to address. |
Notifications
Push notifications and their cleanup. See Notifications.
| Key | Description |
|---|---|
NOTIFICATION_ACTIVE | Enables push notifications. |
NOTIFICATION_ICON | Default notification icon. |
NOTIFICATION_USE_ALIAS | Address devices by alias. |
NOTIFICATION_LIMIT | Max notifications per run. |
NOTIFICATION_DELETE_DAYS | Days to keep notifications. |
One Signal
OneSignal push provider credentials. See Notifications.
| Key | Description |
|---|---|
ONESIGNAL_APP_ID | OneSignal app id. |
ONESIGNAL_REST_KEY | OneSignal REST API key. |
Google OAuth credentials. See Providers.
| Key | Description |
|---|---|
GOOGLE_CLIENT | OAuth client id. |
GOOGLE_SECRET | OAuth client secret. |
GOOGLE_REFRESH_TOKEN | OAuth refresh token. |
Google Map
Google Maps provider. See Providers.
| Key | Description |
|---|---|
GOOGLE_MAP_ACTIVE | Enables the Maps provider. |
GOOGLE_MAP_API_KEY | Google Maps API key. |
Microsoft
Microsoft OAuth client. See Providers.
| Key | Description |
|---|---|
MICROSOFT_CLIENT | Microsoft OAuth client id. |
Open AI
OpenAI API access. See Providers.
| Key | Description |
|---|---|
OPEN_AI_KEY | OpenAI API key. |
Ollama
Local Ollama server. See Providers.
| Key | Description |
|---|---|
OLLAMA_URL | Ollama server url. |
Mercado Pago
MercadoPago checkout and webhooks. See Providers.
| Key | Description |
|---|---|
MP_CLIENT_ID | MercadoPago client id. |
MP_CLIENT_SECRET | MercadoPago client secret. |
MP_ACCESS_TOKEN | MercadoPago access token. |
MP_SIGNATURE | Webhook signature secret. |
MP_BACK_URL | Return url after checkout. |
MP_REDIRECT_PATH | OAuth redirect path. |
MP_NOTIFICATION_PATH | Webhook notification path. |
Redis
Redis cache toggle. See Providers.
| Key | Description |
|---|---|
REDIS_ACTIVE | Enables Redis. |
Logs
Retention windows for each log type. See Logging.
| Key | Description |
|---|---|
ACTION_LOG_DELETE_DAYS | Days to keep action logs. |
DEVICE_LOG_DELETE_DAYS | Days to keep device logs. |
ERROR_LOG_DELETE_DAYS | Days to keep error logs. |
QUERY_LOG_DELETE_DAYS | Days to keep query logs. |