Environment variables on Ibexa Cloud¶
Ibexa Cloud automatically generates environment variables based on the Upsun relationships and routes configuration.
It parses PLATFORM_RELATIONSHIPS and PLATFORM_ROUTES environment variables and exposes them as application-specific variables.
Environment variable prefixes are created by converting relationship names to uppercase and replacing hyphens with underscores.
When multiple endpoints are defined for a single relationship, numerical indices are used for all entries except the first one, for example: SOLR, SOLR_1_, SOLR_2.
When multiple services of the same type are present, environment variables are exposed for each service accordingly based on their relationship names.
Relationship naming conventions¶
You can choose relationship names freely in .platform.app.yaml for most services.
The only required names are:
dfs_database- DFS database (required for DFS functionality)redissession- Redis for sessions (required for dedicated session storage)
Common relationship name include:
database- main application databaserediscache- Redis for cacheelasticsearch- Elasticsearch search servicesolr- Solr search service
Database variables¶
For MySQL and PostgreSQL databases, the following variables are generated based on the relationship name (e.g., database):
{RELATIONSHIP_NAME}_URL- full database URL with charset and server version{RELATIONSHIP_NAME}_USER/{RELATIONSHIP_NAME}_USERNAME- database user{RELATIONSHIP_NAME}_PASSWORD- database password{RELATIONSHIP_NAME}_HOST- database host{RELATIONSHIP_NAME}_PORT- database port{RELATIONSHIP_NAME}_NAME/{RELATIONSHIP_NAME}_DATABASE- database name{RELATIONSHIP_NAME}_DRIVER- database driver{RELATIONSHIP_NAME}_SERVER- database server
For example, for a relationship called database the environment variables are named DATABASE_URL, DATABASE_HOST, DATABASE_USER, etc.
For more information about database configuration, see Databases.
DFS database variables¶
When using distributed file storage (DFS) using a separate database, you must use the relationship name dfs_database.
In addition to the database variables listed above, additional DFS-specific variables are created when PLATFORMSH_DFS_NFS_PATH is set:
DFS_NFS_PATH- NFS path for DFS storageDFS_DATABASE_CHARSET- database character setDFS_DATABASE_COLLATION- database collation
Cache variables¶
For Redis and Memcached cache services, the following variables are available.
{RELATIONSHIP_NAME}_URL(Redis only){RELATIONSHIP_NAME}_HOST{RELATIONSHIP_NAME}_PORT{RELATIONSHIP_NAME}_SCHEME(Redis only)
In addition, the following global variables are defined:
CACHE_POOL- eithercache.redisorcache.memcachedCACHE_DSN- cache connection string
Note
Redis services have higher priority than Memcached services when building the global cache variables.
For more information about persistence cache configuration, see Persistence cache.
Session variables¶
For Redis-based session storage, the following variables are available.
SESSION_HANDLER_ID- session handler class nameSESSION_SAVE_PATH- Redis connection inhost:portformat
The system looks for a relationship named redissession first. If not found, it uses the first available Redis service.
For more information about session configuration, see Sessions.
Search engine variables¶
Solr¶
For Solr search engine configuration, the following variables are generated:
SEARCH_ENGINE- set tosolrSOLR_DSN- Solr connection stringSOLR_CORE- Solr core name{RELATIONSHIP_NAME}_HOST{RELATIONSHIP_NAME}_PORT{RELATIONSHIP_NAME}_NAME/{RELATIONSHIP_NAME}_DATABASE
For more information, see Solr search engine.
Elasticsearch¶
For Elasticsearch search engine configuration, the following variables are generated:
SEARCH_ENGINE- set toelasticsearchELASTICSEARCH_DSN- Elasticsearch connection string{RELATIONSHIP_NAME}_URL{RELATIONSHIP_NAME}_HOST{RELATIONSHIP_NAME}_PORT{RELATIONSHIP_NAME}_SCHEME
For more information, see Elasticsearch.
HTTP cache variables (Varnish)¶
For Varnish-based HTTP caching, the following variables are available.
HTTPCACHE_PURGE_TYPE- set tovarnishHTTPCACHE_PURGE_SERVER- Varnish server addressHTTPCACHE_VARNISH_INVALIDATE_TOKEN- token for cache invalidation
For more information about HTTP cache and Varnish configuration, see HTTP cache.