Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Values of variables that depend on APP_ENV change according to its position #32595

Copy link
Copy link
Closed
@MGatou

Description

@MGatou
Issue body actions

Description
In my .env file, I have a variable TEST that depends on the APP_ENV variable like this:

# .env file

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=2eb810c79fba0dd5c029a2fa53bfdb51
###< symfony/framework-bundle ###

TEST=foo_${APP_ENV}

I run composer dump-env dev command to generate my .env.locale.php, everything works fine, the value of my variable TEST is correct.

// .env.locale.php

return array (
  'APP_ENV' => 'dev',
  'TEST' => 'foo_dev',
  'APP_SECRET' => '2eb810c79fba0dd5c029a2fa53bfdb51',
);

Then I run the same command with prod environment (composer dump-env prod), the value of TEST is wrong (it is same as for dev)

// .env.locale.php

return array (
  'APP_ENV' => 'prod',
  'TEST' => 'foo_dev',
  'APP_SECRET' => '2eb810c79fba0dd5c029a2fa53bfdb51',
);

But when I put my variable TEST before the APP_ENV like this:

# .env file

TEST=foo_${APP_ENV}

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=2eb810c79fba0dd5c029a2fa53bfdb51
###< symfony/framework-bundle ###

And I run composer dump-env prod again, the value of TEST is correct

// .env.locale.php

return array (
  'APP_ENV' => 'prod',
  'TEST' => 'foo_prod',
  'APP_SECRET' => '2eb810c79fba0dd5c029a2fa53bfdb51',
);

How can we explain that ?

How to reproduce

  • Create a new Symfony project composer create-project symfony/skeleton bug_app
  • Add new variable TEST in your .env
  • Run composer dump-env prod
  • Take a look at .env.locale.php
  • In your .env file, put your TEST variable before the APP_ENV
  • Then run composer dump-env prod again
  • Take a look at .env.locale.php again

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDotenvHelp wantedIssues and PRs which are looking for volunteers to complete them.Issues and PRs which are looking for volunteers to complete them.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.