Skip to content

dump-env changes semantics of quoting #682

@ostrolucky

Description

@ostrolucky

ELASTICSEARCH_CONFIG=[{"host":"localhost","port":9200}] in .env.local is evaluated as '[{"host":"localhost","port":9200}]', but running dump-env turns it into
'[{host:localhost,port:9200}]'

12:59 $ ls .env.*
.env.local
12:59 $ cat bin/console
#!/usr/bin/env php
<?php

use Symfony\Component\Dotenv\Dotenv;

require dirname(__DIR__).'/vendor/autoload.php';

// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
  $_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
  throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
  // load all the .env files
  (new Dotenv(false))->load(dirname(__DIR__).'/.env');
}

echo $_ENV['ELASTICSEARCH_CONFIG'];die;
12:59 $ bin/console
[{"host":"127.0.0.1","port":9200}]✔ /vagrant/f2-indexer-2 [master|✚ 3…4]
13:00 $ cat .env.local
ELASTICSEARCH_CONFIG=[{"host":"localhost","port":9200}]
13:00 $ composer dump-env prod
Deprecation warning: require.ruflin/Elastica is invalid, it should not contain uppercase characters. Please use ruflin/elastica instead. Make sure you fix this as Composer 2.0 will error.
Successfully dumped .env files in .env.local.php
13:00 $ ls .env.*
.env.local  .env.local.php
13:00 $ bin/console
[{host:localhost,port:9200}]✔ /vagrant/f2-indexer-2 [master|✚ 3…5]
13:00 $ cat .env.local.php
<?php

// This file was generated by running "composer dump-env prod"

return array (
  'APP_ENV' => 'prod',
  'ELASTICSEARCH_CONFIG' => '[{host:localhost,port:9200}]',
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions