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

dump-env always looks for the .env file in the project-root #855

Closed
predyke opened this issue Jan 24, 2022 · 1 comment · Fixed by #867
Closed

dump-env always looks for the .env file in the project-root #855

predyke opened this issue Jan 24, 2022 · 1 comment · Fixed by #867

Comments

@predyke
Copy link

predyke commented Jan 24, 2022

Problem

Given the situation that I relocated the env files lookup from root to root/my-custom-folder. It works just fine with configuring runtime variables (dotenv_path) in the composer.json.

"runtime": {
   "dotenv_path": "env/.env",
}

However when I want to dump-env the variables into a php file I run into the problem that the symfony:dump-env command always looks for the project root instead of using the newly configured env folder.

In the DumpEnvCommand class the path is hardcoded.

class Symfony\Flex\Command\DumpEnvCommand

protected function execute(InputInterface $input, OutputInterface $output): int
{
        if ($env = $input->getArgument('env')) {
            $_SERVER['APP_ENV'] = $env;
        }

        $path = $this->options->get('root-dir').'/.env';

Proposed solutions:

  • Either add an optional argument to the command (path) where the lookup path for .env could be overridden (this seems to be the easiest solution)

  • Get the location of the env files from runtime somehow? (haven't done any proof of concept about this yet)

Symfony version: v.6.0.0
Flex version: v1.18.1

@tony-sol
Copy link

Have same issue, and sadly that "--root-dir" option is not working.

nicolas-grekas added a commit to symfony/symfony that referenced this issue Feb 18, 2022
…ng dump command (nicolas-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[Dotenv] Fix reading config for symfony/runtime when running dump command

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Same as symfony/flex#867
Fix symfony/flex#855

Commits
-------

376abbe [Dotenv] Fix reading config for symfony/runtime when running dump command
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 a pull request may close this issue.

2 participants