Skip to content
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

[9.x] Extract ServeCommand env list to static property #42444

Merged
merged 2 commits into from
May 19, 2022

Conversation

rasmuscnielsen
Copy link
Contributor

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.

return in_array($key, [
    'APP_ENV',
    'LARAVEL_SAIL',
    'PHP_CLI_SERVER_WORKERS',
    'PHP_IDE_CONFIG',
    'SYSTEMROOT',
    'XDEBUG_CONFIG',
    'XDEBUG_MODE',
    'XDEBUG_SESSION',
]) ? [$key => $value] : [$key => false];

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_ or LARAVEL_.
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.

@taylorotwell taylorotwell merged commit 534188b into laravel:9.x May 19, 2022
@zolotov88
Copy link

Laravel Octane do the same things. It is a reason why do not use it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants