Skip to content

Add alternative configurations, add throwing exceptions to Config class #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 29, 2021

Conversation

devanych
Copy link
Member

@devanych devanych commented May 19, 2021

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues #14

Alternative configurations complement (do not override) the root configuration.

Adding it to composer.json for the root package:

"config-plugin-environments": {
    "alfa": {
        "params": "config/alfa/params.php",
        "web": "config/alfa/web.php",
        "main": [
            "$web",
            "config/alfa/main.php"
        ]
    }
},

Getting the configuration of the alternative build group:

$config new Config($rootPath, $configsPath, 'alfa');

$config->get('main');

Getting the configuration of the root build group:

$config new Config($rootPath, $configsPath);
$config->get($groupName);

@devanych devanych added the status:under development Someone is working on a pull request. label May 19, 2021
@samdark
Copy link
Member

samdark commented May 27, 2021

@yiiliveext suggests to rename "alternatives" to "environments".

@samdark samdark requested review from yiiliveext and vjik May 27, 2021 20:18
@samdark samdark added status:code review The pull request needs review. and removed status:under development Someone is working on a pull request. labels May 28, 2021
Copy link
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't work if application use option source-directory.

Error:

λ yii serve

Fatal error: Uncaught ErrorException: The "/" configuration build does not exist. in E:\open-source\yiisoft\yii-dev-tool\dev\config\src\Config.php on line 365

ErrorException: The "/" configuration build does not exist. in E:\open-source\yiisoft\yii-dev-tool\dev\config\src\Config.php on line 365

Call Stack:
    0.0003     405976   1. {main}() E:\open-source\yiisoft\yii-dev-tool\dev\demo\yii:0
    0.0538    4844960   2. Yiisoft\Config\Config->get($group = 'console', $build = ???) E:\open-source\yiisoft\yii-dev-tool\dev\demo\yii:22
    0.0538    4844960   3. Yiisoft\Config\Config->buildGroup($group = 'params', $build = '/', $rootBuildGroupConfig = ???) E:\open-source\yiisoft\yii-dev-tool\dev\config\src\Config.php:68
    0.0538    4844960   4. Yiisoft\Config\Config->checkBuildGroup($group = 'params', $build = '/') E:\open-source\yiisoft\yii-dev-tool\dev\config\src\Config.php:101
    0.0538    4845280   5. Yiisoft\Config\Config->throwException($message = 'The "/" configuration build does not exist.') E:\open-source\yiisoft\yii-dev-tool\dev\config\src\Config.php:314

@devanych
Copy link
Member Author

Don't work if application use option source-directory.

Did you regenerate merge_plan.php?

This PR changes its format.

@vjik
Copy link
Member

vjik commented May 29, 2021

Don't work if application use option source-directory.

Did you regenerate merge_plan.php?

This PR changes its format.

Oh, sorry. Yes, it's work.

Copy link
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When getting alternative configuration params from alternatives should merged with params from general configuration and then pass both to general configs and alternative configs.

Now merged params pass only to alternative configs. In general configs pass only general params. This is wrong behavior.

@devanych
Copy link
Member Author

When getting alternative configuration params from alternatives should merged with params from general configuration and then pass both to general configs and alternative configs.

Now merged params pass only to alternative configs. In general configs pass only general params. This is wrong behavior.

Done.

@devanych devanych requested a review from vjik May 29, 2021 14:59
@devanych
Copy link
Member Author

@yiiliveext suggests to rename "alternatives" to "environments".

Done.

@samdark samdark merged commit 47fcf74 into master May 29, 2021
@samdark samdark deleted the add-alternative-configurations branch May 29, 2021 21:17
@samdark
Copy link
Member

samdark commented May 29, 2021

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants