yiisoft / config

Configuration management
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
31 stars 11 forks source link

Improve error message when there is a conflict between configs from different groups #109

Closed siamskoi closed 2 years ago

siamskoi commented 2 years ago

Redefinition does not work for the interface DataResponseFactoryInterface

What steps will reproduce the problem?

1) Create project composer create-project --prefer-dist --stability=dev yiisoft/app yii-test 2) add DataResponseFactoryInterface::class => DataResponseFactory::class to config/common/psr17.php

What is the expected result?

Worked app

What do you get instead?

ErrorException:

Duplicate key "Yiisoft\DataResponse\DataResponseFactoryInterface" in configs:
- $common
- config/common/psr17.php

Additional info

Q A
Version 1.1.0
PHP version 8.0, 8.1
Operating system Debian, MacOS
samdark commented 2 years ago

Happens because the config override happens in "common" group while the original resides in "web". As a first step @devanych fixed app and app-api templates to use "web" group. But we need to think more either about allowing such override or about having a better error message.