PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 11, 2022

[FIXED] Symfony: Loading .env.test files

 January 11, 2022     symfony, symfony4     No comments   

Issue

I thought this PR fixed the issue I am having - but I have this patch and it's still not working as I expected - what am I missing or mis-understanding?

https://github.com/symfony/symfony/pull/28533

I have created a .env.test with the following:

DATABASE_URL_TEST=mysql://apps:@localhost:3306/mydb_test

Then I dropped a doctrine.yaml inside the config/packages/test directory.

Symfony v4.2.3

However when I run this command from CLI:

APP_ENV=test bin/console doctrine:database:create --env=test

I am getting an error:

Environment variable not found: "DATABASE_URL_TEST".

Clearly the .env.test file is not being loaded - how do I get a specific environment configuration file to load - other than .env???


Solution

If indeed your application was a Symfony 3.x application at some point, what I would guess is that, during the upgrade process, those two lines out of the UPGRADE procedure were missed:

Then, upgrade the contents of your console script and your front controller:

  • bin/console: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
  • public/index.php: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php

Indeed, it seems like bin/console have been changed recently to reflect the adaptation done on the DotEnv component: https://github.com/symfony/recipes/commit/3e471cbc7d359b3ab245f3b0748d698e8d29692c#diff-2af50efd729ff8e61dcbd936cf2b114b

Mind that you'll also need https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php



Answered By - β.εηοιτ.βε
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing