Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables set in _config.php are not picked up in .yml #8911

Open
AljosaB opened this issue Apr 9, 2019 · 2 comments
Open

Environment variables set in _config.php are not picked up in .yml #8911

AljosaB opened this issue Apr 9, 2019 · 2 comments

Comments

@AljosaB
Copy link

AljosaB commented Apr 9, 2019

Affected Version

SS 4.3.3

Description

Environment variables set in /app/_config.php with Environment::setEnv or via EnvironmentLoader are not available in .yml config. In example below all links point to www.ccc.com instead of www.aaa.com or www.bbb.com

Director.alternate_base_url is used only for example (couldn't find a better one).

Steps to Reproduce

/app/_config.php

<?php

use SilverStripe\Core\EnvironmentLoader;
use SilverStripe\Core\Environment;

Environment::setEnv('BBB', 'true');

// https://docs.silverstripe.org/en/4/getting_started/environment_management/#including-an-extra-env-file
$env = BASE_PATH . '/app/.env';
$loader = new EnvironmentLoader();
$loader->loadFile($env);

/app/.env

AAA=true

/app/_config/mysite.yml

---
Name: myproject
---
SilverStripe\Core\Manifest\ModuleManifest:
  project: app

SilverStripe\Control\Director:
  alternate_base_url: 'http://www.ccc.com'

---
Only:
  envvarset: 'AAA'
---
SilverStripe\Control\Director:
  alternate_base_url: 'http://www.aaa.com'

---
Only:
  envvarset: 'BBB'
---
SilverStripe\Control\Director:
  alternate_base_url: 'http://www.bbb.com'
@chillu
Copy link
Member

chillu commented Jun 28, 2019

This is a documented feature, and pretty crucial to many infrastructure setups, so I'm raising prio to high. https://docs.silverstripe.org/en/4/getting_started/environment_management/

@azt3k
Copy link
Contributor

azt3k commented Apr 28, 2022

I have run into this issue for the first time in 4.10.4, previously this was working on other 4.x releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants