[RFC] Support env-dependent config in one yaml file

Inspired by #40214

For routing/DI, it might be worth merging per-env yaml files (as found in recipes) in one, don’t you think?

My proposal would be to go with a suffix:

services@dev:
    App\FooForDev: ~

framework:
    secret: '%%env(APP_SECRET)%%'

framework@test:
    test: true
    session:
        storage_factory_id: session.storage.mock_file

WDYT?

3 thoughts on “[RFC] Support env-dependent config in one yaml file

  1. Here’s a proposal for an alternative notation: use @dev, @prod, @test as the special prefixes under which you can define services/params only for dev/prod/test:

    framework:
        secret: '%%env(APP_SECRET)%%'
    
    @dev:
        services:
            App\FooForDev: ~
    
    @test:
        framework:
            test: true
            session:
                storage_factory_id: session.storage.mock_file
  2. Main benefit of configuration files is simplicity and declarative nature. The more complicated the syntax and more powerful features, the more difficult it is to use and debug. A few more iterations and we have a programming language which is too complicated, ugly, unsupported by IDE, poorly documented, formally messed up, full of compatibility compromises, … please don’t do it.

    I really like the per-env directories. It is simple and obvious. I also like .env.*.local and .env.* files. It is exaclty what is mostly needed. If you need more powerful configuration, you are likely overengineering it.

    Not so long ago I’ve read something about promoting PHP config in Symfony. (I think something in relation to https://www.reddit.com/r/PHP/comments/h93fjc/symfony_will_now_promote_php_over_yaml_and_xml/.) We should go there.