foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Can't change environment type in Bundles.php

Open ashraf-96 opened this issue 2 years ago • 11 comments

I have two different development environments (dev/dev_api) and when I change the environment in config/bundles.php and in package yaml file I got this error below: CODE: bundles.php return [ Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev_api' => true, 'test' => true], ]; zenstruck_foundry.yaml when@dev: &dev_api zenstruck_foundry: auto_refresh_proxies: true when@test: *dev_api

Error: image

Version : "zenstruck/foundry": "^1.34" Any help please ?

ashraf-96 avatar Jul 17 '23 14:07 ashraf-96

hello,

shouldn't it be like this?

Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'dev_api' => true, 'test' => true]

nikophil avatar Jul 17 '23 14:07 nikophil

Hi ! I tried it, same error shown

ashraf-96 avatar Jul 17 '23 14:07 ashraf-96

please provide more information:

  • full zenstruck_foundry.yaml file
  • in which environment are you working?

nikophil avatar Jul 17 '23 14:07 nikophil

please provide more information:

  • full zenstruck_foundry.yaml file
  • in which environment are you working?

nikophil avatar Jul 17 '23 14:07 nikophil

zenstruck_foundry.yaml

image

Env: Symfony: 5.4 Docker version 20.10.21, build 20.10.21-0ubuntu1~20.04.2

ashraf-96 avatar Jul 17 '23 14:07 ashraf-96

seems something is missing:

when@dev_api: *dev

but the problem does not come from here I think

when I was talking about which environment I was meaning dev|test|prod|dev_api :sweat_smile:

please also could you provide a full stacktrace? (add -v option to the command which creates the problem)

nikophil avatar Jul 17 '23 14:07 nikophil

sorry about mis-understanding, I'm working on dev_api environment. stack strace: image

ashraf-96 avatar Jul 17 '23 15:07 ashraf-96

I want to change the environment type inside the bundle instead of changing it for the whole project, I tried to change it in .env to "dev" and it worked, I'm creating factories successfully but if I want to do it the other way around it doesn't work.

ashraf-96 avatar Jul 17 '23 15:07 ashraf-96

I want to change the environment type inside the bundle instead of changing it for the whole project

not sure what you mean here? why do you want to achieve this? the environment is set for the whole app, not at bundle's level.

the error is weird: it seems the app does not load Foundry's config :thinking:

nikophil avatar Jul 17 '23 15:07 nikophil

I just want the bundle to work in the dev_api environment, somewhow at the bundle's level, it's not getting the dev_api environment, it's getting dev Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true], and I got the error when I change it to : Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'dev_api' => true,'test' => true], Did you get what I mean ?

ashraf-96 avatar Jul 17 '23 15:07 ashraf-96

yes, but it really not sounds like a Foundry problem: the bundle is agnostic of the app's environment.

maybe it would help if you can create a public reproducerr

nikophil avatar Jul 17 '23 15:07 nikophil