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
Allow Multiple Config Classes for Each Type #8
Conversation
So something like this might be in a `composer.json`:
{
"extra": { "aura": {
"type": "project",
"config": {
"common": [
"Acme\\Example\\_Config\\AuraSql",
"Acme\\Example\\_Config\\Twig"
],
"dev": "Acme\\Example\\_Config\\Dev"
}
} }
}
A bigger application might want to separate configuration into several
different classes. Normal strings still work, but arrays may be used as
well.
|
Hey @chrisguitarguy , Thank you for the PR . I was discussing with @pmjones over auraphp/Aura.Intl@0afd245#commitcomment-7231183 . May be I should have opened an issue. One thing I noticed working on it is the type. I feel the type should be an array. "type": {
"project": {
"config": {
"common": [
"Acme\\Example\\_Config\\AuraSql",
"Acme\\Example\\_Config\\Twig"
],
"dev": "Acme\\Example\\_Config\\Dev"
}
},
"library": {
"config": {
"common": [
"Acme\\Example\\_Config\\AuraSql",
"Acme\\Example\\_Config\\Twig"
],
"dev": "Acme\\Example\\_Config\\Dev"
}
}
}The idea of making type as an array is the library, bundle etc have different priority. Thank you. |
|
That doesn't make much sense to me. Actually, the concept of having a type doesn't make much sense to me based on the current code. If something needs to be configured, it will probably be configured the same way regardless of whether its a library or project. To do otherwise seems to violate the principle of least astonishment. I like this a lot: if (is_string($config->common)) {
$this->config_classes[$type][] = $config->common;
} else {
$values = array_values((array) $config->common);
$this->config_classes[$type] = array_merge($this->config_classes[$type], $values);
}Much better solution than what I wrote. More flexible. |
|
@chrisguitarguy I don't know whether you get me on this. The Let us look into an example. Take https://github.com/harikt/Aura.Asset_Bundle/blob/master/config/Common.php#L15-L22 . $di->params['Aura\Asset_Bundle\AssetResponder'] = array(
'response' => $di->lazyGet('web_response'),
);
$di->params['Aura\Asset_Bundle\AssetAction'] = array(
'domain' => $di->lazyNew('Aura\Asset_Bundle\AssetService'),
'responder' => $di->lazyNew('Aura\Asset_Bundle\AssetResponder'),
);You can see the call for But I may be wrong to understand the Principle of least astonishment |
Gotcha, that makes more sense. This is a super clever way to accomplish that, just didn't pick up on the reasoning behind it until you mentioned something. Would there ever be a call for more than one type? |
I didn't get this :( . Could you please expand ? |
|
In your example: { "type": {
"project": {
"config": {
"common": [
"Acme\\Example\\_Config\\AuraSql",
"Acme\\Example\\_Config\\Twig"
],
"dev": "Acme\\Example\\_Config\\Dev"
}
},
"library": {
"config": {
"common": [
"Acme\\Example\\_Config\\AuraSql",
"Acme\\Example\\_Config\\Twig"
],
"dev": "Acme\\Example\\_Config\\Dev"
}
}
} }It seems like the benefit of using the more complex structure is that a package could have more than one type. If that's the case: how does the |
ok, thanks for letting me know. No only one type. What I wanted was if we are doing it on the https://github.com/auraphp/Aura.Web_Project/blob/master/composer.json#L31-L37 . See Web_Project and not on library or bundle or anything. Only on the root composer.json . The reason behind it is if some libraries may have missed the type https://github.com/auraphp/Aura.Input/blob/master/composer.json#L43-L47 we could add in the project. And you should note that , |
|
And all the changes in the PR and the one mentioned will only happen at Aura.Project_Kernel/src/Project.php Line 186 in f26dec4
|
Makes it a bit easier to handle objects vs arrays in the JSON.
Ah, I see what you mean, I think. The idea of allowing multiple "types" in a root project would be to allow adding subprojects. Like Seems like something to be resolved in another pull request or issue? |
|
I like it! @chrisguitarguy thanks for the PR and the collegial work, and of course many thanks to @harikt for giving this such competent attention. Well done guys. |
Allow Multiple Config Classes for Each Type
|
@pmjones there are still somethings that are not done. Eg multiple types. What are your thoughts on that ? Only for the root project it will be helpful. |
|
@harikt You mention earlier that multiples types per package seems unwise, and I agree with that assessment. |
Yes, but for the project it is nice to have. I mean inside the json of Aura.Web_Project if there is a way to add multiple types it seems nice. Do you get me ? Eg : When Aura.Input v1 is not getting the config/Common in the composer.json . Thanks |
|
I think I get you, but I don't think "multiple types" is needed. At the project level, you override the settings from the underlying levels. You can still override, e.g., Aura.Input when you want to. |
ok. May be I am not aware how to do then other than adding in the |
|
Anyway it is not necessary :) . |
So something like this might be in a
composer.json:A bigger application might want to separate configuration into several
different classes. Normal strings still work, but arrays may be used as
well.