Platform.sh exposes information to your application via environment variables, including database credentials, the SMTP address, and more.
Platform.sh exposes environment variables about the application and infrastructure. In addition, Symfony projects exposes some more:
SYMFONY_CACHE_DIR
(only available during the build hook execution): The absolute path to a subdirectory of our build cache directory.The build cache directory is persisted between builds, but is not deployed. It’s a good place to store build artifacts, such as downloaded files, that can be reused between builds.
Note
This directory is shared by all builds on all branches, make sure your build hook accounts for that.
Tip
If you need to clear the build cache directory, use the
cloud:project:clear-build-cache
command.SYMFONY_PROJECT_DEFAULT_ROUTE_URL
(only defined at runtime): The default endpoint serving your project. It can be used to avoid hard-coding domains that can be used to reach non-production environments. Parts of the URL are also exposed as their own variables whose name starts withSYMFONY_PROJECT_DEFAULT_ROUTE_
followed by the name of the part (SCHEME
,DOMAIN
,PORT
, andPATH
).Guessing the default endpoint is usually straightforward but can become complicated for multi-routes or multi-applications projects. For these cases, the following preference order is used:
- project wide route defined only by
{default}
or{all}
(no path) - project wide route defined by
www.{default}
orwww.{all}
(no path) - route for the current application including
{default}
or{all}
(might include a path) - route for the current application including
www.{default}
orwww.{all}
(might include a path) - first route for the current application
- 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.
Tip
For multi-applications projects where several applications are publicly reachable, but one needs to determine the current application endpoint (for webhooks for example) and the project endpoint (to send emails for instance), an additional
SYMFONY_APPLICATION_DEFAULT_ROUTE_*
environment variables set is available. The same rules are applied to determine their value but only routes matching the current application are evaluated.- project wide route defined only by
For Symfony projects, information about services are also exposed via environment variables (see below to learn more about the specifics for each service type). List all available environment variables with the following command:
$ symfony ssh -- symfony var:export --multiline
The following sections lists all exposed environment variables that are automatically defined for each service. Each environment variable is prefixed by the relationship name. For instance, given the following relationships:
relationships:
database: "securitydb:postgresql"
Environment variables for the database will be prefixed by DATABASE_
, the upper-cased version of the key defined in the relationship.
The configuration is exposed via the following environment variables:
MAILER_ENABLED
: 1 if outgoing emails are enabled, 0 otherwiseMAILER_DSN
/MAILER_URL
: The Symfony-compatible mailer URLMAILER_HOST
: The SMTP server hostMAILER_PORT
: The SMTP server portMAILER_TRANSPORT
: The SMTP transport mode (smtp
)MAILER_AUTH_MODE
: The SMTP auth mode (plain
)MAILER_USER
: The SMTP server userMAILER_PASSWORD
: The SMTP server password
Symfony Mailer uses the value of MAILER_DSN
automatically.
If your project has multiple applications, 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 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 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 the PHP or Go format depending on your application)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_NAME
DATABASE_USERNAME
: The database usernameDATABASE_PASSWORD
: The database password
Tip
The database version and a default charset is included in the database URL. Override them using the DATABASE_VERSION
and DATABASE_CHARSET
environment variables respectively.
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 the PHP or Go format depending on your application)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_NAME
DATABASE_USERNAME
: The database usernameDATABASE_PASSWORD
: The database password
Tip
The database version and a default charset is included in the database URL. Override them using the DATABASE_VERSION
and DATABASE_CHARSET
environment variables respectively.
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 URLREDIS_HOST
: The Redis hostREDIS_PORT
: The Redis portREDIS_SCHEME
: The Redis scheme
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 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 serviceELASTICSEARCH_HOST
: The Elasticsearch hostELASTICSEARCH_PORT
: The Elasticsearch portELASTICSEARCH_SCHEME
: The Elasticsearch protocol scheme (http
orhttps
)
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 hostSOLR_PORT
: The Solr portSOLR_NAME
: The Solr nameSOLR_DATABASE
: An alias forSOLR_NAME
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 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 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 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
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