zenstruck / foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html
MIT License
644 stars 70 forks source link

Can't change environment type in Bundles.php #481

Closed ashraf-96 closed 3 months ago

ashraf-96 commented 1 year ago

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 ?

nikophil commented 1 year ago

hello,

shouldn't it be like this?

Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'dev_api' => true, 'test' => true]
ashraf-96 commented 1 year ago

Hi ! I tried it, same error shown

nikophil commented 1 year ago

please provide more information:

nikophil commented 1 year ago

please provide more information:

ashraf-96 commented 1 year ago

zenstruck_foundry.yaml

image

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

nikophil commented 1 year ago

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)

ashraf-96 commented 1 year ago

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

ashraf-96 commented 1 year ago

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.

nikophil commented 1 year ago

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:

ashraf-96 commented 1 year ago

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 ?

nikophil commented 1 year ago

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