Skip to content

[Dotenv] Add SYMFONY_DOTENV_PATH, consumed by debug:dotenv for custom .env path #52638

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

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 17, 2023

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #47880
License MIT

Continuation of #47901

Introduce SYMFONY_DOTENV_PATH set by DotEnv class and read by the debug:dotenv command to contextualize the debug info with the file that was actually parsed.

The custom path can be set in many ways:

  • Doing a call to (new Dotenv())->bootEnv(dirname(__DIR__).'my/custom/path/to/.env');
  • In composer.json: "extra": { "runtime": { "dotenv_path": "my/custom/path/to/.env" }
  • With the env var: $_SERVER['APP_RUNTIME_OPTIONS'] = ['dotenv_path' => 'my/custom/path/to/.env'];

The dotenv file can be outside of the project_dir.

@GromNaN GromNaN added this to the 7.1 milestone Nov 17, 2023
@carsonbot carsonbot changed the title [DotEnv] Make debug:dotenv command aware of custom dotenv_path [Dotenv] Make debug:dotenv command aware of custom dotenv_path Nov 17, 2023
@GromNaN GromNaN force-pushed the dotenv-custom branch 2 times, most recently from 2433512 to 54b8d8d Compare November 17, 2023 22:27
return substr($filePath, \strlen($this->projectDirectory) + 1);
}

return basename($filePath);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only display the basename if the dotenv file is outside of the project directory.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SYMFONY_DOTENV_PATH env var is a nice feature in itself, let's tell about in in the changelog and in the title of the PR

@GromNaN
Copy link
Member Author

GromNaN commented Nov 20, 2023

The SYMFONY_DOTENV_PATH env var is a nice feature in itself, let's tell about in in the changelog and in the title of the PR

Do you want the Dotenv class to read SYMFONY_DOTENV_PATH for the default .env?

@nicolas-grekas
Copy link
Member

Nope, I want the env var you're proposing to be documented in the changelog

@GromNaN GromNaN changed the title [Dotenv] Make debug:dotenv command aware of custom dotenv_path [Dotenv] Add SYMFONY_DOTENV_PATH, consumed by the debug:dotenv for custom .env path Nov 20, 2023
@GromNaN GromNaN changed the title [Dotenv] Add SYMFONY_DOTENV_PATH, consumed by the debug:dotenv for custom .env path [Dotenv] Add SYMFONY_DOTENV_PATH, consumed by debug:dotenv for custom .env path Nov 20, 2023
@GromNaN GromNaN force-pushed the dotenv-custom branch 3 times, most recently from 165f8b7 to 3dddbf9 Compare November 20, 2023 09:34
Introduce SYMFONY_DOTENV_PATH set by DotEnv class and read by debug:dotenv command
to contextualize the debug info with the file that was actually parsed.
@nicolas-grekas
Copy link
Member

Thank you @GromNaN.

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

Successfully merging this pull request may close these issues.

debug:dotenv command does not respect dotenv_path runtime configuration value
3 participants