0

as part of a training on Stripe on Symfony, I am trying to set up an environment variable for testing.

So I have to set a variable to false for testing. And for other environments, the variable must be true.

So, I did this :

#.env.test:
VERIFY_STRIPE_EVENT=false

and

#.env:
VERIFY_STRIPE_EVENT=true

Next, I want to test if I have the good value.

So in my controller, I test : dd(getenv("VERIFY_STRIPE_EVENT")); with dev environment. But it returns false.

It means that I can't get the variable. Can someone help me please ?

eronn
  • 1,690
  • 3
  • 21
  • 53
  • You defined `.env.test` and `.env`. Now you're speaking of "dev" env. If you didn't mistaken, you need a `.env.dev` file. – DonCallisto Jan 23 '20 at 14:07

3 Answers3

0

Check your APP_ENV you need to have it ind dev and you also need a .env.dev and clear dev cache at the end

Youssef Saoubou
  • 591
  • 4
  • 11
0

Add this to line to .env

APP_ENV=prod

Add this to line to .env.test

APP_ENV=test

Add this to line to .env

APP_ENV=prod

Add this to line to .env.stage

APP_ENV=stage

Now, your getenv("VERIFY_STRIPE_EVENT") will return the correct variable depending on which environment you are in.

afessler
  • 1,374
  • 1
  • 10
  • 8
0

If you did however call config:cache during local development, you can undo this by deleting the bootstrap/cache/config.php file. Otherwise, you might experience that calling getenv() will not return the desired values

Rabib Galib
  • 45
  • 1
  • 11