[9.x] Extract ServeCommand env list to static property #42444
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extracts the hardcoded list of allowed ENV variables from the ServeCommand to a public static property.
Background
Currently the Artisan serve command filters out any host ENV variables that is not explicitly listed in a hardcoded array.
This makes it hard as a developer to add pass additional ENV to the server process - for instance from docker-compose.yml using Sail. The additional ENV can be accessed just fine from CLI but will never be accessible from the browser because it is filtered out from the serve command.
Proposal
Make it easier to allow extra ENV to be passed through to the php built-in server by extracting the above list to a public static property so it can be changed from a ServiceProvider@register/boot function without having to extend and customise the serve command.
Additionally it could be handy to automatically pass through any ENV variable starting with a prefix such as
PUBLIC_
orLARAVEL_
.This is similar to what VUE CLI does by making any ENV variables accessible from client javascript if they start with
VUE_APP_
. This would give the best developer experience as no customisations are needed by the developer.If there is support for this I'm happy to implement it too.