Craft CMS environment variables
Craft CMS reads its configuration from ENV vars. Locally they come from the .env file, on fortrabbit from the ENV vars of the environment in the dashboard.
ENV vars from the template
The Craft CMS software template sets these ENV vars when the app is created. The .env file stays local: Craft's .gitignore keeps it out of the repository.
CRAFT_ENVIRONMENT=${FORTRABBIT_ENVIRONMENT_NAME}
CRAFT_DEV_MODE=false
CRAFT_ALLOW_ADMIN_CHANGES=false
CRAFT_ALLOW_UPDATES=false
CRAFT_SECURITY_KEY=…
CRAFT_STREAM_LOG=true
CRAFT_DB_DRIVER=mysql
CRAFT_DB_SERVER=${FORTRABBIT_DB_HOST}
CRAFT_DB_DSN=mysql:host=${FORTRABBIT_DB_HOST};port=3306;dbname=${FORTRABBIT_DB_NAME}
CRAFT_DB_USER=${FORTRABBIT_DB_USER}
CRAFT_DB_PASSWORD=${FORTRABBIT_DB_PASSWORD}
The ${FORTRABBIT_…} values are platform variables that fortrabbit fills in. An app created without the Craft CMS template, or with deleted ENV vars, needs them added by hand:
Multi-environment configuration
CRAFT_ENVIRONMENT holds the name of the fortrabbit environment, for example production. Craft config files can group settings by that name, and the local .env sets its own:
CRAFT_ENVIRONMENT=dev
See the Craft docs on configuration for the multi-environment config syntax.
Table prefix
A local installation with a table prefix needs the same prefix on fortrabbit. Add it to the local .env and to the ENV vars of the environment:
CRAFT_DB_TABLE_PREFIX=craft_