ENV Vars
Read server values (get_cfg_var) first, fall back to Docker env vars (env), then a default.
1. Server PHP_SETTINGS (prod)
Add the variable as a new line in PHP_SETTINGS (php.ini):
server_VAR = your-value
2. Docker environment (local)
Add the variable under environment: in docker-compose.yml:
environment:
docker_VAR: your-value
3. PHP
Read the server value first, fall back to the Docker value, then to a default:
$value = get_cfg_var('server_VAR')
?: env('docker_VAR')
?: 'defaultVal';
get_cfg_var()returnsfalseandenv()returnsnullwhen not set, so?:moves on to the next source.- An empty value also counts as not set.
- Example: the database URLs in
config/app_DEV.php.