Config injection #46227
Unanswered
MelchiorKokernoot
asked this question in
Ideas
Config injection
#46227
Replies: 3 comments 4 replies
-
How does this work for config files with values like |
Beta Was this translation helpful? Give feedback.
2 replies
-
I would remove the name-based resolution and go forward with the attributes; that's exactly the stuff they were incorporated into the language for, and looks very Laravel-y to me! |
Beta Was this translation helpful? Give feedback.
1 reply
-
Cool! i think this would be a great default Laravel feature. I was looking for it but couldn't find it in the documentation anywhere. It would make components even more testable. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have been working on a poc where I am injecting config values through constructor arguments, like so:
This will automatically inject the value of
config('app.name')
into$appName
.I have also created a way to do this with annotations like so:
currently the behaviour is only triggered on classes that extend
AutowiresConfigs
but it is also possible to get here for any class.Finally I have also found a way to do this with primitive types, so:
The package can be found here for further inspection, but I am really interested what the general opinion is about this. Should I create a PR so this is supported by the framework?
Kind regards,
Melchior
Beta Was this translation helpful? Give feedback.
All reactions