Upsun User Documentation

Configure environment variables

Try Upsun for 15 days
After that, enjoy the same, game-changing Upsun features for less with the First Project Incentive!ยน A monthly $19 perk!
ยนTerms and conditions apply
Activate your 15-day trial

By default, Upsun exposes some environment variables. If you’re using the Symfony integration, more infrastructure environment variables related to Symfony are defined.

As Symfony relies heavily on environment variables to configure application services (such as the database or the mailer DSN), the Symfony integration automatically defines environment variables for all the services connected to your app.

Symfony environment variables Anchor to this heading

Upsun exposes environment variables about the app and its infrastructure.

The Symfony integration exposes more environment variables:

  • APP_ENV is set to prod by default. You can manually override this value for a preview environment by setting the SYMFONY_ENV environment variable to dev, and remove it when done.

  • APP_DEBUG is set to 0 by default. You can manually override this value for a preview environment by setting the SYMFONY_DEBUG environment variable to 1, and remove it when done.

  • APP_SECRET is set to the value of PLATFORM_PROJECT_ENTROPY, which is a random and unique value for all Upsun projects. It overrides the value configured in the .env file of your app.

  • MAILFROM is set to a random value. This value is used as a From header when using croncape.

  • SYMFONY_IS_WORKER is set to 1 when the container is running in the context of a worker (instead of the main application container).

  • SYMFONY_CACHE_DIR (only available during the build hook execution): The absolute path to a subdirectory of your build cache directory.

    Note that the build cache directory is persisted between builds but isn’t deployed. Itโ€™s a good place to store build artifacts, such as downloaded files that can be reused between builds.

    If you need to clear the build cache directory, run the symfony upsun:project:clear-build-cache command.

  • SYMFONY_PROJECT_DEFAULT_ROUTE_URL (only defined at runtime): The default endpoint serving your project. Use this variable to avoid hard-coding domains that can be used to reach preview environments. Parts of the URL are also exposed as their own variables using the following syntax: SYMFONY_PROJECT_DEFAULT_ROUTE_ followed by the name of the part (SCHEME, DOMAIN, PORT, and PATH).

    Guessing the default endpoint can prove difficult for multi-routes or multi-app projects. In such cases, the following preference order is used:

    1. Project-wide route defined only by {default} or {all} (no path)
    2. Project-wide route defined by www.{default} or www.{all} (no path)
    3. Route for the current application including {default} or {all} (might include a path)
    4. Route for the current application including www.{default} or www.{all} (might include a path)
    5. First route for the current application
    6. First route for the whole project

    When several routes match a rule, the first one wins, the user order is kept. There’s no preference regarding protocols.

Service environment variables Anchor to this heading

When using the Symfony integration, information about services are exposed via environment variables.

To list all of the exposed environment variables, run the following command:

symfony ssh -- symfony var:export --multiline

Each exposed environment variable is prefixed by the relationship name. For example, if you have the following relationships in your configuration:

.upsun/config.yaml
applications:
  myapp:
    relationships:
      database:
        service: securitydb
        endpoint: postgresql

The environment variables for the database service is prefixed by DATABASE_ which is the upper-cased version of the key defined in the relationship. For example, you could have a DATABASE_URL environment variable.

Most environment variable names are derived from the relationship and service names. But some are defined based on Symfony conventions, such as MAILER_DSN.

Emails Anchor to this heading

The configuration is exposed via the following environment variables:

  • MAILER_ENABLED: 1 if outgoing emails are enabled, 0 otherwise
  • MAILER_DSN/MAILER_URL: The Symfony-compatible mailer URL
  • MAILER_HOST: The SMTP server host
  • MAILER_PORT: The SMTP server port
  • MAILER_TRANSPORT: The SMTP transport mode (smtp)
  • MAILER_AUTH_MODE: The SMTP auth mode (plain)
  • MAILER_USER: The SMTP server user
  • MAILER_PASSWORD: The SMTP server password

Symfony Mailer automatically uses the value of MAILER_DSN.

HTTP Anchor to this heading

If your project has multiple apps, the configuration is exposed via the following environment variables (where SOME_SERVICE is the upper-cased version of the key defined in the relationship):

  • SOME_SERVICE_URL: The full URL of the service
  • SOME_SERVICE_IP: The HTTP service IP
  • SOME_SERVICE_PORT: The HTTP service port
  • SOME_SERVICE_SCHEME: The HTTP service scheme
  • SOME_SERVICE_HOST: The HTTP service host

MySQL/MariaDB Anchor to this heading

The MySQL/MariaDB configuration is exposed via the following environment variables (where DATABASE is the upper-cased version of the key defined in the relationship above):

  • DATABASE_URL: The database URL (in PHP or Go format depending on your app)
  • DATABASE_SERVER: The database server
  • DATABASE_DRIVER: The database driver
  • DATABASE_VERSION: The database version
  • DATABASE_HOST: The database host
  • DATABASE_PORT: The database port
  • DATABASE_NAME: The database name
  • DATABASE_DATABASE: Alias for DATABASE_NAME
  • DATABASE_USERNAME: The database username
  • DATABASE_PASSWORD: The database password

PostgreSQL Anchor to this heading

The PostgreSQL configuration is exposed via the following environment variables (where DATABASE is the upper-cased version of the key defined in the relationship):

  • DATABASE_URL: The database URL (in PHP or Go format depending on your app)
  • DATABASE_SERVER: The database server
  • DATABASE_DRIVER: The database driver
  • DATABASE_VERSION: The database version
  • DATABASE_HOST: The database host
  • DATABASE_PORT: The database port
  • DATABASE_NAME: The database name
  • DATABASE_DATABASE: Alias for DATABASE_NAME
  • DATABASE_USERNAME: The database username
  • DATABASE_PASSWORD: The database password

Redis Anchor to this heading

The Redis configuration is exposed via the following environment variables (where REDIS is the upper-cased version of the key defined in the relationship):

  • REDIS_URL: The Redis URL
  • REDIS_HOST: The Redis host
  • REDIS_PORT: The Redis port
  • REDIS_SCHEME: The Redis scheme

Memcached Anchor to this heading

The Memcached configuration is exposed via the following environment variables (where CACHE is the upper-cased version of the key defined in the relationship):

  • CACHE_HOST
  • CACHE_PORT
  • CACHE_IP

Elasticsearch Anchor to this heading

The Elasticsearch configuration is exposed via the following environment variables (where ELASTICSEARCH is the upper-cased version of the key defined in the relationship):

  • ELASTICSEARCH_URL: The full URL of the Elasticsearch service
  • ELASTICSEARCH_HOST: The Elasticsearch host
  • ELASTICSEARCH_PORT: The Elasticsearch port
  • ELASTICSEARCH_SCHEME: The Elasticsearch protocol scheme (http or https)

Solr Anchor to this heading

The Apache Solr configuration is exposed via the following environment variables (where SOLR is the upper-cased version of the key defined in the relationship):

  • SOLR_HOST: The Solr host
  • SOLR_PORT: The Solr port
  • SOLR_NAME: The Solr name
  • SOLR_DATABASE: An alias for SOLR_NAME

RabbitMQ Anchor to this heading

The RabbitMQ configuration is exposed via the following environment variables (where RABBITMQ is the upper-cased version of the key defined in the relationship):

  • RABBITMQ_URL: The RabbitMQ standardized URL
  • RABBITMQ_SERVER: The RabbitMQ server
  • RABBITMQ_HOST: The RabbitMQ host
  • RABBITMQ_PORT: The RabbitMQ port
  • RABBITMQ_SCHEME: The RabbitMQ scheme
  • RABBITMQ_USER: The RabbitMQ username
  • RABBITMQ_USERNAME: The RabbitMQ username
  • RABBITMQ_PASSWORD: The RabbitMQ password

MongoDB Anchor to this heading

The MongoDB configuration is exposed via the following environment variables (where MONGODB is the upper-cased version of the key defined in the relationship):

  • MONGODB_SERVER
  • MONGODB_HOST
  • MONGODB_PORT
  • MONGODB_SCHEME
  • MONGODB_NAME
  • MONGODB_DATABASE
  • MONGODB_USER
  • MONGODB_USERNAME
  • MONGODB_PASSWORD

InfluxDB Anchor to this heading

The InfluxDB configuration is exposed via the following environment variables (where TIMEDB is the upper-cased version of the key defined in the relationship):

  • TIMEDB_SCHEME
  • TIMEDB_HOST
  • TIMEDB_PORT
  • TIMEDB_IP

Kafka Anchor to this heading

The Apache Kafka configuration is exposed via the following environment variables (where KAFKA is the upper-cased version of the key defined in the relationship):

  • KAFKA_URL
  • KAFKA_SCHEME
  • KAFKA_HOST
  • KAFKA_PORT
  • KAFKA_IP

Is this page helpful?