-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Detect unused environment variables in .env #49161
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
base: 7.4
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this way of demonstrating usage of each variable.
Here is the output for symfony/demo
. We can see that APP_ENV
is not used by the container (because it is used earlier).
$ bin/console debug:container --env-vars
Symfony Container Environment Variables
=======================================
------------------- ------------------ ------------------------------------------------------- -------------
Name Default value Real value Usage count
------------------- ------------------ ------------------------------------------------------- -------------
APP_ENV n/a "dev" 0
APP_SECRET n/a "2ca64f8d83b9e89f5f19d672841d6bb8" 8
DATABASE_URL n/a "sqlite:///%kernel.project_dir%/data/database.sqlite" 1
VAR_DUMPER_SERVER "127.0.0.1:9912" n/a 3
------------------- ------------------ ------------------------------------------------------- -------------
// Note real values might be different between web and CLI.
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
Outdated
Show resolved
Hide resolved
@GromNaN Thanks for the suggestions, I made changes in the code. |
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet an other review, sorry it's so fragmented on my part.
Improved
bin/console debug:container --env-vars
and the--env-var
option to display the number of occurrences of each environment variable in the container. This allows you to identify unused variables from .env files.Example usage:
php bin/console debug:container --env-vars
php bin/console debug:container --env-var=APP_SECRET