-
Hi, I've just passed a considerable amount of time trying to debug a potential composer issue ( However, turns out you simply can't use I would like to know if this is a known behaviour, maybe it has a very precise reason to work that way? If this behaviour can't be changed, how do you think one could access an envvar inside said callback? Sample of what I would like to do: ->withMiddleware(function (Middleware $middleware) {
$middleware->trustProxies(at: config("trust-proxies.docker-network-ip-range", "172.17.0.0/16"));
}) Thanks for your time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Laravel suggest caching configs and not using the env inside the app. Interesting how this limitation (that we saw also here https://github.com/laravel/lumen/blob/b18a7652aa2dec5fd96c23693933fef32eca9a88/bootstrap/app.php#L9) comes into place. Would be interesting to see if the old laravel 10 way of bootstrapping the app has this issue. |
Beta Was this translation helpful? Give feedback.
It doesn't because of order of operations IIRC. I don't remember when exactly the middleware stack gets created without the use of this highly annoying application builder, but the
withMiddleware()
callback is run after the kernel is resolved from the container, which comes before the kernel call's the application'sbootstrapWith()
method with its bootstrapper list. The kernel bootstrappers include tasks such as loading the configuration, registering the core service providers, and early setup tasks like that.So this
withMiddleware()
callback is going to be run at a point before the frameworkβ¦