Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.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 ourterms of service andprivacy 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
GromNaN left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 forsymfony/demo
. We can see thatAPP_ENV
is not used by the container (because it is used earlier).
$bin/console debug:container --env-varsSymfony 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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
@GromNaN Thanks for the suggestions, I made changes in the code. |
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
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.
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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