enhancementgood first issue
Description
| Q | A |
|---|---|
| Bug report? | no |
| Feature request? | yes |
Right now we can create custom configuration based on presets, however I think it would be worth allowing custom presets also.
This would mean opening up the Preset interface so for example a framework could maintain their own Preset file and users can then use the preset, just by pointing their preset configuration to the class.
Implementation
- In
Configuration::resolveConfig, theOptionsResolvernow has to allowpresetto also be a valid class. - In
ConfigResolver::resolve, add a new private methodresolvePreset, which has the current logic for resolving a preset, but also adds support for the preset variable could be a class fqn. - Add docs
- Add a test in
ConfigResolverTestfor setting preset from a class - Remove internal from phpdoc in
Presetinterface - Consider if we should also remove internal from
Composerclass - Remove
shouldBeAppliedandgetNamefromPresetinterface and add it to a new internal interface, which our presets implements. (this method is used for guessing the preset from composer, but does not make sense with custom preset as their are not registered in our application.)
Usage
Using this should be rather straight forward, creating a custom Preset should be like this
class LaravelLumenPreset implements Preset
{
public static function get(Composer $composer): array
{
$config = [
// My custom configs
];
return ConfigResolver::mergeConfig(LaravelPreset::get($composer), $config);
}
}
And our config file would then look like
return [
'preset' => FQN\LaravelLumenPreset::class,
...