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

Overriding defaults #37

Closed
johnrobertporter opened this Issue Jun 30, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@johnrobertporter

johnrobertporter commented Jun 30, 2017

https://github.com/josegonzalez/php-dotenv/blob/master/src/josegonzalez/Dotenv/Loader.php#L220

I was under the impression that this package allowed merging of values from all files in the filepaths array. I see now that it doesn't.

Is there any chance this could be altered to merge and replace instead of just replace?

@josegonzalez

This comment has been minimized.

Show comment
Hide comment
@josegonzalez

josegonzalez Jun 30, 2017

Owner

Would you be fine with making that an opt-in not default?

Owner

josegonzalez commented Jun 30, 2017

Would you be fine with making that an opt-in not default?

@johnrobertporter

This comment has been minimized.

Show comment
Hide comment
@johnrobertporter

johnrobertporter Jul 1, 2017

After further reading of the code (I extended the class) I noticed that it's handled inside the loop. That got me thinking, that the api could be extended to allow custom processing of the file contents within that loop?

I'm not sure if that isn't overthinking it though.

An option to allow continuing the loop instead of breaking it would be ok though :D

johnrobertporter commented Jul 1, 2017

After further reading of the code (I extended the class) I noticed that it's handled inside the loop. That got me thinking, that the api could be extended to allow custom processing of the file contents within that loop?

I'm not sure if that isn't overthinking it though.

An option to allow continuing the loop instead of breaking it would be ok though :D

@tanakahisateru

This comment has been minimized.

Show comment
Hide comment
@tanakahisateru

tanakahisateru Sep 19, 2017

Contributor

My workaround:

$dotenvLoader = new josegonzalez\Dotenv\Loader();
foreach ([
    __DIR__ . '/../.env',
    __DIR__ . '/../.env.default',
] as $path) {
    $dotenvLoader->setFilepath($path)->parse()->skipExisting()->toEnv()->putenv();
}
Contributor

tanakahisateru commented Sep 19, 2017

My workaround:

$dotenvLoader = new josegonzalez\Dotenv\Loader();
foreach ([
    __DIR__ . '/../.env',
    __DIR__ . '/../.env.default',
] as $path) {
    $dotenvLoader->setFilepath($path)->parse()->skipExisting()->toEnv()->putenv();
}
@stefanvangastel

This comment has been minimized.

Show comment
Hide comment
@stefanvangastel

stefanvangastel Nov 27, 2017

Contributor

Same solution here. We wanted to use DotEnv combined with Docker so sometimes have an .env file and with defaults and sometimes 'overwrite' or pre-set env var's with Docker. This resulted in errors or overwriting the Docker pre-defined env var's.

skipExisting() solved this issue so the Docker env var's remain intact.

Contributor

stefanvangastel commented Nov 27, 2017

Same solution here. We wanted to use DotEnv combined with Docker so sometimes have an .env file and with defaults and sometimes 'overwrite' or pre-set env var's with Docker. This resulted in errors or overwriting the Docker pre-defined env var's.

skipExisting() solved this issue so the Docker env var's remain intact.

@josegonzalez

This comment has been minimized.

Show comment
Hide comment
@josegonzalez

josegonzalez Nov 27, 2017

Owner

Closing as a workaround exists :)

Owner

josegonzalez commented Nov 27, 2017

Closing as a workaround exists :)

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