-
Notifications
You must be signed in to change notification settings - Fork 63
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
[Idea] config(...)
call to typed Config::*
calls
#279
Comments
This would be such a cool rule to have. I wonder how would we determine the type from the config file though.
|
I've thought about this as well in the past. It's the same for the Request object as well. The biggest problem is being sure what the intention of the user is. It could be that it's a configurable rule that makes it more obvious e.g. you specify, ['foo.bar' => 'string'] but that doesn't feel very smart. The other option would be to use the configs themselves to make an educated guess but that could run into problems. I feel like there might be a middle ground for this, namely a mix of the two. We know that Laravel predefines certain Laravel config keys, so we could have a compiled list of keys from the framework. We could also introduce a command that would do an analysis of the keys in the config. This command could then try to guess the appropriate type and build the config, then the end user can edit the config as appropriate. |
If a configuration value accepts |
Hello 👋🏽
Laravel 11 introduced typed config retrieval methods like
Config::string
,Config::integer
etc.We could then convert
config('foo.bar')
toConfig::string('foo.bar')
We need to parse the config file and determine the actual type to be able to do this.The text was updated successfully, but these errors were encountered: