-
-
Notifications
You must be signed in to change notification settings - Fork 791
Add support for local config #66
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
Conversation
|
@yiisoft/core-developers need opinions about these changes. |
composer.json
Outdated
| }, | ||
| "scripts": { | ||
| "post-install-cmd": [ | ||
| "php -r \"if(!file_exists('config/console-local.php')){copy('config/templates/console-local.php', 'config/console-local.php');}\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer moving these operations to the separate method of yii\composer\Installer class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
The reasons for creating local configs are not obvious for beginners. The idea should be well documented: why local config is under |
|
Yeah. It's not obvious for advanced app users as well despite being documented. |
Conflicts: .travis.yml tests/codeception/config/acceptance.php tests/codeception/config/functional.php tests/codeception/config/unit.php
|
Synced with master and added docs about local configs. Gladly would see some progress for my PRs for |
|
+1 |
|
I am for adding a simple local config concept to the basic application because it is a needed feature in nearly every project. But it should not make things too complex. local configs should not use main.php: <?php
$config = [
// ...
];
if (file_exists($localConfig = __DIR__ . '/main.local.php')) {
require($localConfig);
}
return $config;main.local.php: <?php
$config['components']['redis'] = 'yii\redis\Connection';Array manipulation is more basic and easier to understand than recursive merge. A minor thing about naming, I prefer |
|
Agree. |
About what situations you're talking about? |
|
example: [
'params' => [
'adminUsers' => ['cebe', 'samdark'],
],
]main.local.php: [
'params' => [
'adminUsers' => ['rob006'],
],
]the final result will contain all users. that is not expected. |
|
I would say that this is expected - this is how My approach also scales much better - if you have many custom local settings, storing them as array is much more readable. If you decide to extract settings shared between console and web app (to About |
The main point about not introducing I feel the need for a third application template between basic and advanced here. |
the less files the better. IMO its better to start as small as possible and give advice how to expand than the other way around. Alls these config files are not making the life of a developer easier (especially when you don't have experience with it). In all of my projects I am now trying to minimize the number of config files. The less you have, the less you have to manage. |
|
How about adding the code that will include a local config file if it exists but do not create the templates? |
|
looks good. I like it better than the array merging because its more tightly connected to its owner. |
|
We need at least two templates for local configs: one for DB settings and second for |
|
Sorry guys but implementing changes proposed by @cebe require more work than I suspected, and I don't want to burn more time on this since I'm not using this template anymore. Consider this PR as finished. If you want additional changes on this, someone else has to do it. |
|
@rob006 no problem, thank you for your contribution! We will decide on how to proceed with this later and make the necessary changes. |
|
OK. Thank you for contributing! |
# Conflicts: # .travis.yml # README.md
|
In result of internal discussion, we decided that this PR brings too much complexity as for basic application template so the PR will be closed. @rob006 thank you for your contribution and sorry that this one is rejected. |
replaces #60
closes #69
Simplified version of #60 without environment-specific config files.