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

[4.1] Support multiple file names and disabling short circuit file loading #394

Merged
merged 4 commits into from
Dec 11, 2019

Conversation

GrahamCampbell
Copy link
Collaborator

@GrahamCampbell GrahamCampbell commented Dec 10, 2019

It is now possible to specify multiple file names, as well as multiple directories to search. By default, we'll stop looking for files as soon as we find one, like we did when there were multiple directories. To disable this behaviour, and load all files in order, one can disable "short circuit" file loading with a new parameter.

For example:

// load both .env and .env2 if found
// if only one file exists, load it
// if no files exist, crash
$dotenv = \Dotenv\Dotenv::create(__DIR__, ['.env', '.env2'], false);
$dotenv->load();

Closes #393.

@GrahamCampbell
Copy link
Collaborator Author

Oh, I should also mention, if more control over the exact paths tried is needed (such as only looking for some files in some directories, and files of a different name in others), instead of using the static create functions, you can directly "new" up the class. Please take a look at the code for the constructor, and the code for the create static functions. It should be obvious how to use it, with maximal flexibility from that.

@GrahamCampbell
Copy link
Collaborator Author

We now support getting the raw file contents too, before they are parsed and loaded.

@KarelWintersky
Copy link

I'll test it a bit later :)

@GrahamCampbell
Copy link
Collaborator Author

Pushed another change. Don't want to make read available on the Dotenv class.

@GrahamCampbell GrahamCampbell merged commit a6bd169 into master Dec 11, 2019
@GrahamCampbell GrahamCampbell deleted the shortcircuit-config branch December 11, 2019 14:14
@GrahamCampbell
Copy link
Collaborator Author

GrahamCampbell commented Dec 11, 2019

This code is currently available as:

    "require": {
        "vlucas/phpdotenv": "^4.1@dev"
    },

@GrahamCampbell
Copy link
Collaborator Author

I'm going to give some more time for feedback before I release 4.1.0.

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

Successfully merging this pull request may close these issues.

Add ability to load multiply _ENV files
2 participants