mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8633 from falnyr/patch-1
Referencing env vars in configs
This commit is contained in:
commit
1b68157e39
@ -48,6 +48,22 @@ use SilverStripe\Core\Environment;
|
|||||||
Environment::setEnv('API_KEY', 'AABBCCDDEEFF012345');
|
Environment::setEnv('API_KEY', 'AABBCCDDEEFF012345');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using environment variables in config
|
||||||
|
|
||||||
|
To use environment variables in `.yaml` configs you can reference them using backticks.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
SilverStripe\Core\Injector\Injector:
|
||||||
|
MyServiceClass:
|
||||||
|
properties:
|
||||||
|
MyProperty: '`ENV_VAR_HERE`'
|
||||||
|
```
|
||||||
|
|
||||||
|
<div class="info">
|
||||||
|
<p>Environment variables cannot be used outside of Injector config as of version 4.2.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
## Including an extra `.env` file
|
## Including an extra `.env` file
|
||||||
|
|
||||||
Sometimes it may be useful to include an extra `.env` file - on a shared local development environment where all
|
Sometimes it may be useful to include an extra `.env` file - on a shared local development environment where all
|
||||||
|
Loading…
Reference in New Issue
Block a user