upsun project:init includes
the environment variables for all the services connected to your app in the .environment file.
Tip
You can tweak the.environment configuration to fit your needs and add specific project-level variables.You may need a variable to change per environment. If so, use the
upsun variable command to add all the needed per-environment variables.Default environment variables
Upsun automatically exposes environment variables about the app and its infrastructure. Assuming that MySQL, PostgreSQL, and Redis services have been added to your environment, and that the app has been granted access to those services via the following relationships:.upsun/config.yaml
.environment file:
.environment
Service environment variables
Each exposed environment variable is prefixed by the relationship name. For example, if you have the following relationships in your configuration:.upsun/config.yaml
DATABASE_,
which is the upper-cased version of the key defined in the relationship.
For example, you could have a DATABASE_URL environment variable.
Emails
Upsun provides a SMTP service for sending emails. To configure email in Laravel, add the following mapping to your.environment file:
.environment
HTTP
If your project has multiple apps, the configuration is exposed via the following environment variables (whereSOME_SERVICE is the upper-cased version of the key defined in the relationship):
SOME_SERVICE_URL: The full URL of the serviceSOME_SERVICE_IP: The HTTP service IPSOME_SERVICE_PORT: The HTTP service portSOME_SERVICE_SCHEME: The HTTP service schemeSOME_SERVICE_HOST: The HTTP service host
MySQL/MariaDB
The MySQL/MariaDB configuration is exposed via the following environment variables (whereDATABASE 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 serverDATABASE_DRIVER: The database driverDATABASE_VERSION: The database versionDATABASE_HOST: The database hostDATABASE_PORT: The database portDATABASE_NAME: The database nameDATABASE_DATABASE: Alias forDATABASE_NAMEDATABASE_USERNAME: The database usernameDATABASE_PASSWORD: The database password
Tip
The database version and a default charset are included in the database URL. To override them, use theDATABASE_VERSION and DATABASE_CHARSET environment variables respectively.PostgreSQL
The PostgreSQL configuration is exposed via the following environment variables (whereDATABASE 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 serverDATABASE_DRIVER: The database driverDATABASE_VERSION: The database versionDATABASE_HOST: The database hostDATABASE_PORT: The database portDATABASE_NAME: The database nameDATABASE_DATABASE: Alias forDATABASE_NAMEDATABASE_USERNAME: The database usernameDATABASE_PASSWORD: The database password
Tip
The database version and a default charset are included in the database URL. To override them, use theDATABASE_VERSION and DATABASE_CHARSET environment variables respectively.Redis
The Redis configuration is exposed via the following environment variables (whereREDIS is the upper-cased version of the key defined in the relationship):
REDIS_URL: The Redis URLREDIS_HOST: The Redis hostREDIS_PORT: The Redis portREDIS_SCHEME: The Redis scheme
.environment file:
.environment
Memcached
The Memcached configuration is exposed via the following environment variables (whereCACHE is the upper-cased version of the key defined in the relationship):
CACHE_HOSTCACHE_PORTCACHE_IP
Elasticsearch
The Elasticsearch configuration is exposed via the following environment variables (whereELASTICSEARCH is the upper-cased version of the key defined in the relationship):
ELASTICSEARCH_URL: The full URL of the Elasticsearch serviceELASTICSEARCH_HOST: The Elasticsearch hostELASTICSEARCH_PORT: The Elasticsearch portELASTICSEARCH_SCHEME: The Elasticsearch protocol scheme (httporhttps)
RabbitMQ
The RabbitMQ configuration is exposed via the following environment variables (whereRABBITMQ is the upper-cased version of the key defined in the relationship):
RABBITMQ_URL: The RabbitMQ standardized URLRABBITMQ_SERVER: The RabbitMQ serverRABBITMQ_HOST: The RabbitMQ hostRABBITMQ_PORT: The RabbitMQ portRABBITMQ_SCHEME: The RabbitMQ schemeRABBITMQ_USER: The RabbitMQ usernameRABBITMQ_USERNAME: The RabbitMQ usernameRABBITMQ_PASSWORD: The RabbitMQ password
MongoDB
The MongoDB configuration is exposed via the following environment variables (whereMONGODB is the upper-cased version of the key defined in the relationship):
MONGODB_SERVERMONGODB_HOSTMONGODB_PORTMONGODB_SCHEMEMONGODB_NAMEMONGODB_DATABASEMONGODB_USERMONGODB_USERNAMEMONGODB_PASSWORD
InfluxDB
The InfluxDB configuration is exposed via the following environment variables (whereTIMEDB is the upper-cased version of the key defined in the relationship):
TIMEDB_SCHEMETIMEDB_HOSTTIMEDB_PORTTIMEDB_IP
Kafka
The Apache Kafka configuration is exposed via the following environment variables (whereKAFKA is the upper-cased version of the key defined in the relationship):
KAFKA_URLKAFKA_SCHEMEKAFKA_HOSTKAFKA_PORTKAFKA_IP