How can I hide my passwords and other sensitive environment variables on-screen in Laravel's whoops output?
Sometimes other people are looking at my development work. I don't want them to see these secrets if an exception is thrown, but I also don't want to have to keep toggling debug on and off, or spin up a dedicated site just for a quick preview.
Thanks Jeff and Raheel for helping out, but I just found a little gotcha:
Even if I clear out all environment keys from
_ENV
, the same keys are STILL exposed through the_SERVER
variables listed.Adding the code below in
config/app.php
would hide all environment variables from the whoops page:As of Laravel 5.5.13, there's a new feature that allows you to blacklist certain variables in
config/app.php
under the keydebug_blacklist
. When an exception is thrown, whoops will mask these values with asterisks*
for each character.For example, given this
config/app.php
Results in this output:
First of all, love the solution by Jeff above.
2nd, if like me you wanna hide all the
env variables
while still use whoops, here is a solution:Output:
Laravel 5.6 not works for my. but this works:
I would be grateful for a better solution.
I've made a package to solve this problem.
Just install it using
Most of the server and all the env variables will be removed. Any password-like fields in
$_POST
will have their values hidden.You can also customize it in either blacklist or whitelist approach to show/obfuscate/remove fields however you like.