Gacela configuration for different envs (gacela-test.php)
JesusValera opened this issue Β· comments
issue related to this discussion: https://github.com/gacela-project/gacela/discussions/88
π Description
Currently, the Gacela configuration is on the gacela.php
file, on this file we are able to define the mapping interfaces on the mappingInterfaces()
method, the problem we can face is we want to define certain interface (e.g: Logger
or DB
) on production, but on a feature test we just want to use mocks/spies for those interfaces.
With this scenario, it would be interesting to be able to define another gacela-{$env}.php
file for this purpose.
The question is:
Should be allow to define only for testing environment (gacela-test.php
) OR any environment.
I wouldn't limit this feature to be only for "testing environments", because what are "testing environments"? I would simply allow any env: gacela-{$env}.php
, and the APP_ENV
will rule them all.
I'm obviously still new to Gacela...
Looking at this... it looks like there is a constant set in:
So can we make this constant a configurable value like we do here:
Then what about fallback if a custom ENV variable is not present in the config?
@webcraftniray yes, the constant gacela.php
you mention is the first thing you should change in order to achieve this ticket.
The idea is the gacela-dev.php
should override the gacela.php
file (if both files exists and we are in dev
environment).
One suggestion @Chemaclass, if we are in dev
environment and we have the following files:
gacela.php
gacela-prod.php
gacela-dev.php
A) Load all files and finally override with the environment file?
B) Load only the gacela.php
and depending on the environment if this file exists, override with this configuration?
In this scenario, we load first gacela.php
and finally gacela-dev.php
.
I think the option B makes more sense, what do you think? π
Regarding your last question @webcraftniray, if the key is not present in gacela.php
either in gacela-dev.php
, it should thrown an exception (unless you define a fallback value), see https://github.com/gacela-project/gacela/blob/master/src/Framework/Config.php#L65
I think you are mixing two concepts. Config key-values
and gacela.php
.
gacela.php
[andGacela::bootstrap()
] is the file that bootstraps the gacela configuration itself.- The Config key-values: are the config file for your application.
I think this could be a bit tricky issue. I would suggest starting with a Good first issue first :)
I would like to take this issue.
Done: #180