Magento application environment variables

The following table lists variables that you can override using environment variables.

Variable name Description Default value
ADMIN_USERNAME User name for a Magento administrative user. This user is an administrator and can create other users, including other administrative users. admin
ADMIN_FIRSTNAME Administrative user's first name. John
ADMIN_LASTNAME Administrative user's last name. Doe
ADMIN_EMAIL Administrative user's e-mail address. john@example.com
ADMIN_PASSWORD Administrative user's password. admin12
ADMIN_URL Enter the relative URL by which to access the Magento Admin. For security reasons, we recommend you choose a value other than admin or backend or another term that is easy to guess. admin
ADMIN_LOCALE Specifies the default locale used by the Magento Admin. en_US
APPLICATION_MODE

Determines whether or not Magento operates in developer mode or in production mode. During deployment, we recommend the default mode.

The variable supports the following values: production and developer. You cannot set this value to default mode. After you have changed the mode with an environment variable, it can only be set to production or developer.

To execute build and deploy scripts in a specific mode, set an environment variable for APPLICATION_MODE. If you execute these scripts in default mode without APPLICATION_MODE set as an environment variable, the mode will be set to production.

production
CLEAN_STATIC_FILES

The default value, enable, cleans generated static view files when you perform an action like enabling or disabling a component. We recommend the default value in development. The supported values are enable and disable.

Failure to clear static view files might result in issues if there are multiple files with the same name and you don't clear all of them.

In other words, because of static file fallback rules, if you do not clear static files and there is more than one file named logo.gif that are different, fallback might cause the wrong file to display.

enable
UPDATE_URLS

On deployment, replace Magento base URLs in the database with project URLs. This is useful for local development, where base URLs are set up for your local environment. When you deploy to a Cloud environment, we change the URLs so you can access your storefront and Magento Admin using project URLs.

You should set this variable to disabled only in staging or production, where the base URLs can't change.

enabled

Add environment variables

You can add environment variables for active environments through the Project web interface and through the Magento Cloud CLI. To create variables through the Project web interface, see Set environment variables.

Everytime you add or modify a variable using the web interface or the CLI, the branch will redeploy automatically.

To create a variable using the command line:

  1. Login to the Magento Cloud CLI. Enter the command magento-cloud login and provide your credentials.
  2. To set a variable for the project, use the command magento-cloud project:variable:set <name> <value>. The alias for this command is also pvset. For example, magento-cloud pvset example 123 creates a variable example with a string value of 123 for the project.
  3. After creating these variables, you can list all project variables with the command magento-cloud project:variable:get or magento-cloud pvget.
  4. To set a variable for the branch, use the command magento-cloud variable:set <name> <value>. The alias for this command is also vset. For example, magento-cloud vset example2 abc creates a variable example2 with a string value of abc for the branch.
  5. After creating these variables, you can list all project variables with the command magento-cloud variable:get or magento-cloud vget.

Troubleshooting

In the event something goes wrong and you can’t access your environment after it deploys, try the following:

  • SSH to the environment and make sure services are running.
  • Restore your snapshot:

    magento-cloud snapshot:list
    magento-cloud snapshot:restore <snapshot>