Welcome Guest, Not a member yet? Register   Sign In
How do nested variables within the .env file work in CodeIgniter 4
#1

Under the "Nesting Variables" section in the CI4 documentation under General Topics -> Configuration:

"To save on typing, you can reuse variables that you’ve already specified in the file by wrapping the variable name within ${...}"
example in the documentation:
Code:
BASE_DIR="/var/webroot/project-root"

CACHE_DIR="${BASE_DIR}/cache"

TMP_DIR="${BASE_DIR}/tmp"


I was trying to use the following
Code:
app.baseURL = 'http://localhost:8080/'

google.redirect = ${app.baseURL}Google

However, it's assigning it as a literal when print_r($_ENV)
Code:
[google.redirect] => ${app.baseURL}Google


I've tried using non-namespaced keys including BASE_DIR (per the example) and it keeps printing as a literal.



What's strange - When I use the following:
Code:
CI_ENVIRONMENT = development

google.redirect = ${CI_ENVIRONMENT}Google

The result when print_r is:
Code:
[CI_ENVIRONMENT] => development

[google.redirect] => developmentGoogle


My question is - What am I doing incorrectly and/or how should these be set/used correctly?
According to the documentation, It makes it seem like I should be able to use any key within the .env file that was already assigned using
${somekeyinthisenvfile}



CI version: 4.0.3
PHP 7.4.0

Using CI CLI
Reply


Messages In This Thread
How do nested variables within the .env file work in CodeIgniter 4 - by Dozor - 06-30-2020, 06:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB