framework icon indicating copy to clipboard operation
framework copied to clipboard

Load config based on APP_ENV

Open gam6itko opened this issue 2 years ago • 2 comments

Description

It would be very useful to be able to load configuration files based on APP_ENV from corresponding folder. Like in a Symfony

Example

Imagine that we have such a file structure

app/
├─ config/
│  ├─ prod/
│  │  ├─ queue.php
│  │  ├─ cache.php
│  ├─ dev/
│  │  ├─ database.php
│  ├─ monolog.php
│  ├─ database.php
│  ├─ cache.php

For APP_ENV=prod configuration loader must first search configs in app/config/prod. If config does not exists then it should take it from default folder app/config.

In this case, files will be loaded from folders:

APP_ENV=prod

  • app/config/prod/queue.php
  • app/config/prod/cache.php
  • app/config/monolog.php
  • app/config/database.php

APP_ENV=dev

  • app/config/dev/database.php
  • app/config/cache.php
  • app/config/monolog.php

APP_ENV=*

  • app/config/database.php
  • app/config/cache.php
  • app/config/monolog.php

gam6itko avatar Jun 21 '23 08:06 gam6itko

It can be done via separate pacakge

butschster avatar Sep 05 '23 08:09 butschster