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 to override .env files per env #481

Merged
merged 1 commit into from Nov 9, 2018

Conversation

Projects
None yet
6 participants
@nicolas-grekas
Member

nicolas-grekas commented Nov 8, 2018

Q A
License MIT

This PR is an alternative to #466 and replaces #479.
It needs symfony/symfony#29129 to work with 4.2.

What we have here:

  • Dotenv is configured to load .env < .env.local < .env.$env < .env.$env.local (only the 1st is required, see PR linked above)
  • this works starting with Symfony 3.4 and uses an optimized code starting with 4.2 (removing the doc-split hell)
  • the loading logic is factorized in a new static Kernel::bootstrapEnv() method
  • the CLI accepts and consumes --env & --no-debug (see Kernel::bootstrapCliEnv(), fixes symfony/symfony#23343)
  • .env files are loaded for tests (fixes symfony/flex#317, symfony/symfony#28895 and symfony/symfony#28726)
  • config for the test env is moved from phpunit.xml.dist to .env.test
  • .env.dist is not created anymore (commit .env instead and use .env.local for local overrides)
  • .gitignore is updated accordingly

Regarding flex integration:

  • this PR doesn't change anything for existing projects - they won't notice
  • when flex sees a .env.test file, it should skip updating phpunit.xml files
  • that's it - all the rest should remain identical, isn't it?
  • (people that still want to use .env.dist just need to create the file and flex will populate it as it does today)
@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@dunglas

dunglas approved these changes Nov 8, 2018

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@nicolas-grekas

This comment has been minimized.

Member

nicolas-grekas commented Nov 9, 2018

I improved the phpunit-bridge integration: it now uses .env files before anything else.
This means .env.test works now to configure the bridge also.
This fixes symfony/symfony#28726

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@nicolas-grekas

This comment has been minimized.

Member

nicolas-grekas commented Nov 9, 2018

PR updated to leverage symfony/symfony#29154

@symfony-flex-server

Pull request passes validation.

@symfony-flex-server

Pull request passes validation.

@chalasr

chalasr approved these changes Nov 9, 2018

@symfony-flex-server symfony-flex-server bot merged commit 95bb543 into symfony:master Nov 9, 2018

1 check passed

continuous-integration/symfony/pr Done
Details

symfony-flex-server bot added a commit that referenced this pull request Nov 9, 2018

@nicolas-grekas nicolas-grekas deleted the nicolas-grekas:env.local branch Nov 9, 2018

umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new Kernel($env, $debug);
$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);

This comment has been minimized.

@Tobion

Tobion Nov 9, 2018

Member

You need to cast $_SERVER['APP_DEBUG'] to boolean to not rely on implicit typecast.

fabpot added a commit to symfony/flex that referenced this pull request Nov 12, 2018

feature #434 Skip updating phpunit.xml files when .env.test exists (n…
…icolas-grekas)

This PR was merged into the 1.1-dev branch.

Discussion
----------

Skip updating phpunit.xml files when .env.test exists

This is to support `.env` < `.env.local` < `.env.test` < `.env.test.local` dotenv files *withouth affecting existing workflows* based on `.env(.dist)` and `phpunit.xml(.dist)`.

Leveraged by symfony/recipes#481

Best reviewed [ignoring whitespaces](https://github.com/symfony/flex/pull/434/files?w=1).

Commits
-------

ae7128a Skip updating phpunit.xml files when .env.test exists
@nem75

This comment has been minimized.

nem75 commented on symfony/phpunit-bridge/4.1/bin/phpunit in 95bb543 Nov 12, 2018

This broke our test setup.

We executed our tests via bin/phpunit, with the configuration in phpunit.xml.dist, where in turn bootstrap="vendor/autoload.php" was configured. Unregistering the class loader here leaves us with no (sensible) autoloading in our test classes.

Using vendor/bin/simple-phpunit this doesn't happen, so we'll use that for now. Any hints as to why this unregister() call is necessary, @nicolas-grekas?

This comment has been minimized.

Member

nicolas-grekas replied Nov 12, 2018

thanks for the notice, fixed in #490

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