Laravel uses Whoops ( filp/whoops ) to create a debug page, and you can see here that uses $_ENV to get environment variables. Although not ideal, you can simply remove $_ENV in case the error occurs in any environment other than local.
This is quite simple to do by simply rewriting App::error (and possibly App::fatal too) into app/start/global.php something like this:
App::error(function(Exception $exception, $code) { Log::error($exception); if (App::environment() !== 'local') { $_ENV = []; } });
This works because the exception handler is called before the Whoops handler.
Now the right, best way to do this is to create a class that extends Whoops\Handler\PrettyPageHandler that does not display environment variables or does not change any other unwanted behavior and, based on the environment, registers it as a whoops.handler component for your application, similar to how it done on Illuminate\Exception\ExceptionServiceProvider:registerPrettyWhoopsHandler . I do not think that it is worth all the trouble.
source share