Replies: 1 comment 1 reply
-
|
I think what Laravel currently has is good enough. The backwards incompatible changes on this would be very broad since packages ship with config files as arrays. We'd either have to have all of those package maintainers update all the packages or support both config paradigms moving forward. Additionally if you wanted to enforce typed configs you could already create a value object, bind it in the service provider, and just pull values from Overall I don't think this is worth the effort, backwards incompatibility, and maintenance of all the existing packages. |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Laravel team,
As time has gone on, I've seen how PHP frameworks have generally 'plugged in' newer PHP features, vs having these features become a foundational way of how the framework works. In most cases it's a lot of work, so I get it - 100%.
With everything going on at the intersection with AI, I wouldn't want to prepare a PR for this until knowing:
a) If it's even feasible
b) If so, what extent of it's features the Laravel team would be interested in
The Laravel config system has always been pretty loose with regards to types, from an application and a vendor standpoint.
Personally, I'm more of a source-diver than a documentation reader but I still find random config values that allow me to tweak this or that at times.
This idea introduces a 'strongly typed config objects'. For the most part, this idea speaks for itself, so here's some examples:
Additionally - and optionally - it'd be great to be able to inject these config objects into other config objects, e.g.
This 2nd example introduces the
#[Inject]attribute (likely using an optional arg that allows the developer to provide the named binding/tag, e.g. #[Inject('reports')]).Personally, I've fleshed out this property injection system as a means of handling memory leaks with Laravel Octane, but this config system is a much better way to introduce the idea and be able to expand on it from there as a framework.
To explain a bit:
private (set)implies that these properties can be set after of the bootstrap period.#[Env]attribute would mean that the framework is injecting those values. This also provides strongly typed/validated values.#[Inject]'d objects. This would allow the dev to have control of any/all levels of config if they need to customize.Feedback welcome!
Beta Was this translation helpful? Give feedback.
All reactions