Craft CMS 6 ENV vars

Published

Updated

Craft CMS 6 reads Laravel's ENV vars. The software template sets them when the app is created.

ENV vars from the template

Version 6 of the Craft CMS software template sets the Laravel and database ENV vars:

Craft CMS 6

DeploymentValue
Root pathpublic
Deploy strategyreplace
Excluded paths/storage/node_modules
Build commandscomposer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
Post-deploy commandsmkdir -p storage/framework/{sessions,views,cache}php artisan migrate --forcephp artisan storage:link --forceif php artisan craft:install:check; then php artisan craft:up; fiif php artisan craft:install:check; then php artisan craft:clear-caches/all; fi
Environment variablesValue
APP_DEBUGfalse
APP_ENVproduction
APP_KEY!RANDOM_KEY!
APP_URLhttps://${FORTRABBIT_MAIN_DOMAIN}
LOG_CHANNELstack
LOG_STACKstderr
Database environment variablesValue
DB_CONNECTIONmysql
DB_DATABASE${FORTRABBIT_DB_NAME}
DB_HOST${FORTRABBIT_DB_HOST}
DB_PASSWORD${FORTRABBIT_DB_PASSWORD}
DB_PORT${FORTRABBIT_DB_PORT}
DB_USERNAME${FORTRABBIT_DB_USER}

The ${FORTRABBIT_…} values are platform variables that fortrabbit fills in. An app created without the template needs them added by hand:

Differences to Craft 5

  • DB_CONNECTION=mysql is needed: the .env.example of the Craft 6 skeleton sets pgsql.
  • APP_KEY replaces CRAFT_SECURITY_KEY. The template generates a random one. Data encrypted locally needs the local key on fortrabbit too.
  • APP_URL sets the URLs of the Control Panel. Without it, links point to localhost.
  • LOG_STACK=stderr sends the logs to the logs of the environment.

Settings in config/craft/general.php read ENV vars with Laravel's env() helper.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗