Framework
Introduction

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:

.env
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.

.env.production
URL       = "https://myapp.com/"
DB_HOST   = "10.0.0.5"
DEBUG     = false

The 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:

.env.local
URL   = "http://localhost:8080/"
DEBUG = true

Each 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.

KeyDescription
NAMEThe application name.
URLThe base url — used by getUrl() and for environment matching.

Database

MySQLi connection, encryption key and slow-query logging. See Database.

KeyDescription
DB_HOSTDatabase host.
DB_PORTDatabase port (default 3306).
DB_DATABASEDatabase name.
DB_USERNAMEDatabase user.
DB_PASSWORDDatabase password.
DB_CHARSETConnection charset (default utf8mb4).
DB_KEYKey used to encrypt stored values.
DB_LOG_TIMESlow-query threshold, in seconds.
DB_SCHEMA_FILEName 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.

KeyDescription
FILE_URLBase url for served files.
FILE_DIRDirectory that stores files (default files).
FILE_FTPDirectory for FTP uploads.

Auth

JWT signing, token lifetimes and API access. See Authentication.

KeyDescription
AUTH_ACTIVEEnables the Auth module.
AUTH_KEYSecret used to sign JWT tokens.
AUTH_HOURSAccess-token lifetime, in hours.
AUTH_DAYSRefresh-token lifetime, in days.
AUTH_FIELDSExtra credential fields to expose.
AUTH_API_TOKENStatic token for server-to-server API access.

Email

Sending, templating, providers and cleanup. See Emails.

KeyDescription
EMAIL_ACTIVEEnables sending email.
EMAIL_USE_WHITE_LISTRestrict recipients to the white list.
EMAIL_PROVIDERWhich transport to send through.
EMAIL_NAMEDefault "from" name.
EMAIL_EMAILDefault "from" address.
EMAIL_REPLY_TODefault reply-to address.
EMAIL_URLBase url used inside email links.
EMAIL_TEMPLATEPath to the HTML email template.
EMAIL_LOGOPath to the email logo image.
EMAIL_LOGO_HEIGHTLogo height, in pixels.
EMAIL_LIMITMax emails per run (0 = no limit).
EMAIL_RECAPTCHA_SECRETreCAPTCHA secret for the contact form.
EMAIL_DELETE_DAYSDays to keep sent emails.

SMTP

Credentials for the built-in SMTP transport. See Email providers.

KeyDescription
SMTP_HOSTSMTP server host.
SMTP_PORTSMTP port.
SMTP_SECUREEncryption (ssl / tls).
SMTP_USERNAMESMTP user.
SMTP_PASSWORDSMTP password.
SMTP_DEBUGVerbose SMTP logging.

Mailjet

Mailjet transport and default contact list. See Email providers.

KeyDescription
MAILJET_KEYMailjet API key.
MAILJET_SECRETMailjet API secret.
MAILJET_LISTDefault contact list id.

Mailgun

Mailgun transport key. See Email providers.

KeyDescription
MAILGUN_KEYMailgun API key.

Mandrill

Mandrill transport key. See Email providers.

KeyDescription
MANDRILL_KEYMandrill API key.

Send Grid

SendGrid transport key. See Email providers.

KeyDescription
SEND_GRID_KEYSendGrid API key.

Mailchimp

Audience sync and campaign sending. See Email providers.

KeyDescription
MAILCHIMP_ACTIVEEnables the Mailchimp integration.
MAILCHIMP_SUBSCRIBER_ACTIVESync subscribers.
MAILCHIMP_CREATE_ACTIVEAllow creating contacts.
MAILCHIMP_SEND_ACTIVEAllow sending campaigns.
MAILCHIMP_KEYMailchimp API key.
MAILCHIMP_LISTAudience / list id.
MAILCHIMP_NAMEDefault "from" name.
MAILCHIMP_REPLY_TODefault reply-to address.

Notifications

Push notifications and their cleanup. See Notifications.

KeyDescription
NOTIFICATION_ACTIVEEnables push notifications.
NOTIFICATION_ICONDefault notification icon.
NOTIFICATION_USE_ALIASAddress devices by alias.
NOTIFICATION_LIMITMax notifications per run.
NOTIFICATION_DELETE_DAYSDays to keep notifications.

One Signal

OneSignal push provider credentials. See Notifications.

KeyDescription
ONESIGNAL_APP_IDOneSignal app id.
ONESIGNAL_REST_KEYOneSignal REST API key.

Google

Google OAuth credentials. See Providers.

KeyDescription
GOOGLE_CLIENTOAuth client id.
GOOGLE_SECRETOAuth client secret.
GOOGLE_REFRESH_TOKENOAuth refresh token.

Google Map

Google Maps provider. See Providers.

KeyDescription
GOOGLE_MAP_ACTIVEEnables the Maps provider.
GOOGLE_MAP_API_KEYGoogle Maps API key.

Microsoft

Microsoft OAuth client. See Providers.

KeyDescription
MICROSOFT_CLIENTMicrosoft OAuth client id.

Open AI

OpenAI API access. See Providers.

KeyDescription
OPEN_AI_KEYOpenAI API key.

Ollama

Local Ollama server. See Providers.

KeyDescription
OLLAMA_URLOllama server url.

Mercado Pago

MercadoPago checkout and webhooks. See Providers.

KeyDescription
MP_CLIENT_IDMercadoPago client id.
MP_CLIENT_SECRETMercadoPago client secret.
MP_ACCESS_TOKENMercadoPago access token.
MP_SIGNATUREWebhook signature secret.
MP_BACK_URLReturn url after checkout.
MP_REDIRECT_PATHOAuth redirect path.
MP_NOTIFICATION_PATHWebhook notification path.

Redis

Redis cache toggle. See Providers.

KeyDescription
REDIS_ACTIVEEnables Redis.

Logs

Retention windows for each log type. See Logging.

KeyDescription
ACTION_LOG_DELETE_DAYSDays to keep action logs.
DEVICE_LOG_DELETE_DAYSDays to keep device logs.
ERROR_LOG_DELETE_DAYSDays to keep error logs.
QUERY_LOG_DELETE_DAYSDays to keep query logs.