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

Allow .env to exist outside of working directory #33

Open
jbboynton opened this issue Dec 30, 2018 · 2 comments
Open

Allow .env to exist outside of working directory #33

jbboynton opened this issue Dec 30, 2018 · 2 comments

Comments

@jbboynton
Copy link

Hey @PhilippBaschke!

As mentioned in the docs, the ACF key can be read from an .env file, as long as the .env and composer.json files are in the same directory. However, I'm working on a project where .env and composer.json are in different directories. The composer.json file is in the root directory, and the .env file is in a subdirectory, like this:

root_directory/
├── composer.json
├── subdirectory/
│   ├── .env

When the loadDotEnv function checks for .env in the current working directory, it doesn't find the .env file in the subdirectory, and my ACF key isn't read.

protected function loadDotEnv()
{
if (file_exists(getcwd().DIRECTORY_SEPARATOR.'.env')) {
$dotenv = new Dotenv(getcwd());
$dotenv->load();
}
}

I'd like to make it possible to specify the path that's passed to the Dotenv constructor on line 246. Does that sound like a feature you'd consider merging?

Thanks for all the hard work you've put into this plugin!
– James

@atticus7
Copy link

I'd love this to be added too.

My .env is in conf directory one level above my root directory

@ffraenz
Copy link

ffraenz commented Jan 22, 2021

@atticus7 As this Composer plugin has not received an update for 5 years you should not depend on it. I am maintaining a package that gives you the same functionality as this one but also offering configurable .env file locations: https://github.com/ffraenz/private-composer-installer

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

No branches or pull requests

3 participants