This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Dotenv
Christian Flothmann 2070e30018 feature #31546 [Dotenv] Use default value when referenced variable is not set (j92)
This PR was squashed before being merged into the 4.4 branch (closes #31546).

Discussion
----------

[Dotenv] Use default value when referenced variable is not set

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/11956 <!-- required for new features -->

In bash you have the option to define a default variable like this:
```bash
FOO=${VARIABLE:-default}
```

When VARIABLE is not set
```bash
FOO=${VARIABLE:-default} #FOO=default
```

When VARIABLE is set:
```bash
VARIABLE=test
FOO=${VARIABLE:-default} #FOO=test
```

If others find this also a good idea, I will write documentation and add the Doc PR. But first I would like some feedback to check if anyone agrees with this feature.

Commits
-------

790dbad149 [Dotenv] Use default value when referenced variable is not set
2019-08-06 09:27:26 +02:00
..
Exception Mark ExceptionInterfaces throwable 2018-08-29 17:58:00 +02:00
Tests feature #31546 [Dotenv] Use default value when referenced variable is not set (j92) 2019-08-06 09:27:26 +02:00
.gitignore [Dotenv] added the component 2017-01-12 08:39:44 -08:00
CHANGELOG.md [Dotenv] fix typos 2019-04-10 22:28:30 +02:00
composer.json Allow Symfony 5.0 2019-05-28 17:53:17 +02:00
Dotenv.php feature #31546 [Dotenv] Use default value when referenced variable is not set (j92) 2019-08-06 09:27:26 +02:00
LICENSE update year in license files 2019-01-01 14:45:19 +01:00
phpunit.xml.dist Merge branch '2.8' into 3.4 2018-11-11 20:48:54 +01:00
README.md [Dotenv] fix typos 2019-04-10 22:28:30 +02:00

Dotenv Component

Symfony Dotenv parses .env files to make environment variables stored in them accessible via $_SERVER, $_ENV and optionally getenv().

Resources